Part Number Hot Search : 
CSA952K UM807TBE 2SD17 PCA9531 GALI5 EKK6111 50031 EVQPSC
Product Description
Full Text Search
 

To Download MC83C0304 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  magnachip semiconductor ltd. 8-bit single-chip microcontrollers mc83f0304/0308/0314 MC83C0304/0308/0316 preliminary user?s manual (ver. 0.2) .com .com .com 4 .com u datasheet
version 0.2 published by mcu application team ? 2005 magnachip semiconductor ltd. all righ t reserved. additional information of this ma nual may be served by magnachip semiconductor offices in korea or distributors and representat ives. magnachip semiconductor reserves the right to make changes to any informat ion here in at any time without notice. the information, diagrams and ot her data in this manual are corre ct and reliable; however, magna chip semiconductor is in no way re- sponsible for any violations of pate nts or other rights of the third part y generated by the use of this manual. revision history version 0.2 (mar. 2005) this book fix some errata. version 0.1 (mar. 2005) this book first edition .com .com .com .com 4 .com u datasheet
mc80f0304/0308/0316 mar. 2005 ver 0.2 1. overview ................................................................................................................... ................................... 1 description .................................................................................................................... ................................... 1 features ...................................................................................................................... .................................... 1 development tools .............................................................................................................. ............................ 2 ordering information .............................................................. ............................................................... ....2 2. block diagram ............................................................................................................... ............................ 3 3. pin assignment .............................................................................................................. ............................. 4 4. package drawing............................................................................................................. ......................... 5 5. pin function ............................................................................................................... ................................. 6 6. port structures ............................................................................................................ .......................... 8 7. electrical charace teristics................................................................................................ ........... 12 absolute maximum ratings ............................... ....................................................................... .................... 12 recommended operating conditions............................................................................................... ............. 12 a/d converter characteristics .................................................................................................. ..................... 12 dc electrical characteristics ................................................................................................. ....................... 13 ac characteristics ............................................................................................................. ............................ 14 typical characteristics ....................................................................................................... ........................... 15 8. memory organization ........................................................................................................ .................. 16 registers ..................................................................................................................... .................................. 16 program memory ................................................................................................................. .......................... 19 data memory .................................................................................................................. ............................. 21 addressing mode ............................................................................................................... ........................... 26 9. i/o ports .................................................................................................................. ................................... 30 r0 and r0io register ........................................................................................................... .......................... 30 r1 and r1io register .......................................................................................................... .......................... 31 r2 and r2io register .......................................................................................................... .......................... 33 r3 and r3io register ........................................................................................................... .......................... 34 10. clock generator ........................................................................................................... ..................... 35 oscillation circuit .......................................................................................................... ............................... 35 11. basic interval timer....................................................................................................... ..................... 37 12. watchdog timer ............................................................................................................. ....................... 39 13. timer/event counter ............ ................. ................ ................ ................ ................ ........... ................... 42 8-bit timer / counter mode .................................................................................................... ....................... 45 16-bit timer / counter mode .................................................................................................... ..................... 50 8-bit compare output (16-bit) .................................................................................................. ...................... 51 8-bit capture mode ............................................................................................................ ........................... 51 16-bit capture mode ........................................................................................................... .......................... 56 pwm mode ...................................................................................................................... ............................. 58 14. analog to digital converter................................................................................................ .......... 62 15. serial input/output (sio).................................................................................................. .................. 65 transmission/receiving timing .. ............................................................................................... ................... 66 the usage of serial i/o ........................................................................................................ .......................... 68 the method to test correct tran smission ....................................................................................... ............. 68 .com .com .com .com 4 .com u datasheet
hms83f022/012 mar. 2005 ver 0.2 16. universal asynchronous receiver/transmitter (uart) ..................................................... 69 uart serial interface functions ................................................................................................ ................... 69 serial interface configuration ................................................................................................. ....................... 70 communication operation ....................................................................................................... ...................... 74 relationship between main clock and baud rate ................................................................................. ......... 75 17. buzzer function ............................................................................................................ ........................ 76 18. interrupts ................................................................................................................. .............................. 78 interrupt sequence ............................................................................................................ ........................... 80 brk interrupt ................................................................................................................. ............................... 82 multi interrupt ............................................................................................................... ................................. 82 external interrup t ............................................................................................................ .............................. 84 19. power saving operation ..................................................................................................... .............. 86 sleep mode .................................................................................................................... ............................... 86 stop mode ..................................................................................................................... ................................ 87 stop mode at internal rc-oscillat ed watchdog timer mode ....................................................................... 90 minimizing current consumption ................................................................................................ .................. 92 20. reset ...................................................................................................................... .................................... 94 21. power fail processor ...................................................................................................... ................. 96 22. countermeasure of noise .................................................................................................... ............ 98 oscillation noise protector.................................................................................................... ......................... 98 oscillation fail processor ..................................................................................................... ......................... 99 23. device configuration area .................................................................................................. ..................... 100 24. mask option (mc80c0316) .................................................................................................... ................. 101 25. emulator eva. board setting ............................................................................................... ................... 102 26. in-system programming (isp) ................ ................ ................ ................ ................ ............... .......... 105 getting started / installation ................................................................................................ ........................ 105 basic isp s/w information ..................................................................................................... ..................... 105 hardware conditions to enter the isp mode ........................... .......................................................... ......... 107 reference isp circuit diagram and magnachip supplied isp board ......... ............................................... 108 .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 1 mc80f0304/0308/0316 mc80c0304/0308/0316 cmos single-chip 8-bit microcontroller with 10-bit a/d converter and uart 1. overview 1.1 description the mc80f0304/0308/0316 is advanced cmos 8-bit microcontrol ler with 4k/8k/16k bytes of flash. this is a powerful microcontroller which provides a highly flexible and cost ef fective solution to many embedded control applications. this provides the following features : 4k/8k/16k bytes of flas h, 256 bytes of ram, 8/16-bit timer/counter, watchdog timer, 10-bit a/d converter, 8-bit se rial input/output, uart, buzzer driving port, 10-bit pwm out put and on-chip oscillator and clock circuitry. it also has onp, noise filter, pfd for improving noise immunity. in addition, the mc80f0304/0308/0316 supports power saving modes to reduce power consumption. this document explaines the base mc80f0316 , the other?s eliminated functions are same as below table. 1.2 features ? 4k/8k/16k bytes on-chip flash ? flash mem ory - endurance : 100 cycles - data retention time : 10 years ? 512 bytes on-chip data ram (included stack memory) ? minimum instruction execution time: - 333ns at 12mhz (nop instruction) ? programmable i/o pins (led direct driving can be a source and sink) - mc80f0316b : 30(29) - mc80c0316g : 26(25) ? one 8-bit basic interval timer ? four 8-bit timer/counters (or two 16-bit timer/counter) ? one watchdog timer ? two 10-bit high speed pwm outputs ? 10-bit a/d converter : 10 channels ? two 8-bit serial communication interface - one serial i/o and one uart ? one buzzer driving port - 488hz ~ 250khz@4mhz ? four external interrupt input ports ? on-chip por (power on reset) ? thirteen interrupt sources - external input : 4 - timer : 6 - a/d conversion : 1 - serial interface : 1 - uart : 1 ? built in noise immunity circuit - noise filter - pfd (power fail detector) - onp (oscillation noise protector) ? power down mode - stop mode - wake-up timer mode - internal rc-oscillat ed watchdog timer mode ? operating voltage & frequency - 2 . 7 v ~ 5 . 5 v ( a t 0 . 4 ~ 8 m h z ) : f l a s h - 2.0v ~ 5.5v (at 0.4 ~ 4.2mhz) : mask - 4.5v ~ 5.5v (at 0.4 ~ 12mhz) : flash,mask ? operating temperature : -40c ~ 85c ? oscillator type device name flash size ram adc i/o port package flash mask rom mc80f0304b/08b/16b mc80c0304b/08b/16b 4k/8k/16k 512b 16 channel 30 port 32 pdip mc80f0304g/08g/16g mc80c0304g/0 8g/16g 16 channel 26 port 28 skdip .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 2 mar. 2005 ver 0.2 - crystal - ceramic resonator - external rc oscillator (c can be omitted) - internal oscillator (4mhz/2mhz) 1.3 development tools the mc80f0304/0308/0316 is supported by a full-featured mac- ro assembler, an in-cir cuit emulator choice-dr. tm and otp programmers. there are two differe nt type of programmers such as single type and gang type. fo r mode detail, macro assembler operates under the ms-windows 95 and upversioned windows os. please contact sa les part of magna chip semiconductor. 1.4 ordering information software - ms-windows based assembler - ms-windows based debugger - hms800 c compiler hardware (emulator) - choice-dr. - choice-dr. eva80c0x b/d flash writer - choice - sigma i/ii(single writer) - pgm plus i/ii/iii(single writer) - standalone gang4 i/ii(gang writer) pgmplus iii ( single writer ) choice-dr. (emulator) standalone gang4 ii ( gang writer ) device name mask rom flash rom ram package mask version mc80c0316b/0316g mc80c0308b/0308g mc80c0304b/0304g 16k bytes 8k bytes 4k bytes - - - 512bytes 32pdip/28skdip 32pdip/28skdip 32sop/28skdip flash version mc80f0316b/0316g mc80f0316b/0308g mc80f0316b/0304g - - - 16k bytes 8k bytes 4k bytes 512 bytes 32pdip/28skdip 32pdip/28skdip 32pdip/28skdip .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 3 2. block diagram alu accumulator stack pointer interrupt controller data memory 10-bit converter a/d 8-bit counter timer/ program memory data table pc 8-bit basic timer interval watch-dog timer instruction r0 r1 buzzer driver psw system controller timing generator system clock controller clock generator reset r00 / int3 / sck r01 / an1 / si r02 / an2 / sout r03 / an3 / int2 r04 / an4 / ec0 / rxd r05 / an5 / t0o / txd r06 / an6 / t2o / aclk r07 / an7 / ec1 r10 / an0 / avref / pwm1o r11 / int0 / pwm3o r12 / int1 / buzo r13 r14 v dd v ss power supply decoder high pwm speed r3 xout / r34 sio/uart r31 / an14 r32 / an15 xin / r33 r2 r20 r21 r22 r23 / an9 r24 / an10 r25 / an11 r26 / an12 r27 r15 r16 r17 / an8 .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 4 mar. 2005 ver 0.2 3. pin assignment 2 3 4 5 6 7 8 27 26 25 24 23 22 21 128 9 10 11 12 13 14 20 19 18 17 16 15 r02 / an2 / sout r01 / an1 / si r00 / int3 / sck vss reset / r35 xout / r34 xin / r33 r32 / an15 r31 / an14 r05 / an5 / t0o / txd r06 / an6 / t2o / aclk r07 / an7 / ec1 v dd r10 / an0 / avref / pwm1o r11 / int0 / pwm3o 32pdip 2 3 4 5 6 7 8 9 10 31 30 29 28 27 26 25 24 23 r12 / int1 / buzo r13 r14 r03 / an3 / int2 r04/an4 / ec0 / rxd 132 r02 / an2 / sout r01 / an1 / si r00 / int3 / sck vss reset / r35 xout / r34 xin / r33 r05 / an5 / t0o / txd r06 / an6 / t2o / aclk r07 / an7 / ec1 v dd r10 / an0 / avref / pwm1o r11 / int0 / pwm3o r12 / int1 / buzo r03 / an3 / int2 r04 / an4 / ec0 / rxd 28 skdip 11 12 13 14 15 16 22 21 20 19 18 17 r15 r16 r17 / an8 r20 r21 r22 r13 r14 r15 r17 / an8 r23 / an9 r30 / an13 r27 r26 / an12 r25 / an11 r24 / an10 r23 / an9 r16 r32 / an15 r31 / an14 r30 / an13 r26 / an12 r25 / an11 r24 / an10 .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 5 4. package drawing 1.375 0.015 0.045 typ 0.100 typ 0.300 0.300 0 . 0 1 4 0 ~ 15 max 0.180 min 0.020 0.120 28 skinny dip unit: inch max min 1.355 0.021 0.140 0.055 0 . 0 0 8 0.275 1.665 0.015 0.045 typ 0.100 typ 0.600 0.550 0 . 0 1 2 0 ~ 15 max 0.190 min 0.015 0.120 1.645 0.022 0.140 0.065 0 . 0 0 8 0.530 32 pdip .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 6 mar. 2005 ver 0.2 5. pin function v dd : supply voltage. v ss : circuit ground. reset : reset the mcu. x in : input to the inverting oscillator amplifier and input to the internal main cl ock operating circuit. x out : output from the inverting oscillator amplifier. r00~r07 : r0 is an 8-bit, cmos, bidirectional i/o port. r0 pins can be used as output s or inputs according to ?1? or ?0? written the their port direction register(r0io). in addition, r0 serves the functions of the various special features in table 5-1 . r10~r14 : r1 is a 5-bit, cmos, bidirectional i/o port. r1 pins can be used as output s or inputs according to ?1? or ?0? written the thei r port direction register (r1io). r1 serves the functions of the various following special features in table 5-2 r20~r21 : r2 is an 8-bit, cmos, bidirectional i/o port. r2 pins can be used as outpu ts or inputs according to ?1? or ?0? written the their po rt direction register(r2io) in addition, r2 serv es the functions of the various special features in table 5-3 . r31~r34 : r3 is a 4-bit, cmos, bidirectional i/o port. r3 pins can be used as outputs or inputs according to ?1? or ?0? written the their port direction register (r3io). r3 serves the functions of the serial interface following special features in table 5-4 . port pin alternate function r00 r01 r02 r03 r04 r05 r06 r07 int3 ( external inte rrupt input port3 ) sck ( spi clk ) an1 ( analog input port 1 ) si (spi serial data input ) an2 ( analog input port 2 ) sout ( spi serial data output ) an3 ( analog input port 3 ) int2 ( external inte rrupt input port2 ) an4 ( analog input port 4 ) ec0 ( event counter input source 0 ) rxd ( uart data input ) an5 ( analog input port 5 ) t0o (timer0 clock output ) txd ( uart data output ) an6 ( analog input port 6 ) t2o (timer2 clock output ) aclk ( uart clock input ) an7 ( analog input port 7 ) ec1 ( event counter input source 1 ) table 5-1 r0 port port pin alternate function r10 r11 r12 r13 r14 r15 r16 r17 an0 ( analog input port 0 ) avref ( external analog reference pin ) pwm1o ( pwm1 output ) int0 ( external interrupt input port 0 ) pwm3o ( pwm3 output ) int1 ( external interrupt input port 1 ) buz ( buzzer driving output port ) - - - - an8( analog input port 8 ) table 5-2 r1 port port pin alter nate function r20 r21 r22 r23 r24 r25 r26 r27 - - - an9 ( analog input port 9 ) an10 ( analog input port 10 ) an11 ( analog input port 11 ) an12 ( analog input port 12 ) - table 5-3 r2 port port pin alternate function r30 r31 r32 r33 r34 r35 an13 ( analog input port 13) an14 ( analog input port 14 ) an15 ( analog input port 15 ) x in ( oscillation input ) x out ( oscillation output ) resetb ( reset input port ) table 5-4 r3 port .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 7 pin name pin no. in/out function 32 28 first second third forth v dd 55 - supply voltage v ss 28 22 - circuit ground reset (r35) 27 21 i reset signal input input only port - - x in (r33) 25 19 i oscillation input normal i/o port - - x out (r34) 26 20 o oscillation output normal i/o port - - r00 (int3/sck) 29 25 i/o normal i/o ports external interrupt 3 spi clock input - r01 (an1/si) 30 26 i/o analog input port 1 spi data input - r02 (an2/sout) 31 27 i/o analog input port 2 spi data output - r03 (an3/int2) 32 28 i/o analog input port 3 external interrupt2 - r04 (an4/ec0/rxd) 1 1 i/o analog input port 4 event counter uart rx r05 (an5/t0o/txd) 2 2 i/o analog input port 5 timer0 output uart tx r06 (an6/t2o/aclk) 3 3 i/o analog input port 6 timer2 output uart clock r07 (an7/ec1) 4 4 i/o analog input port 7 event counter - r10 (an0/avref/pwm1o) 6 6 i/o analog input port 0 analog reference pwm 1 output r11 (int0/pwm3o) 7 7 i/o external interrupt 0 - - r12 (int1/buzo) 8 8 i/o external interrupt 1 buzzer driving output - r13 9 9 i/o --- r14 10 10 i/o --- r15 11 11 i/o --- r16 12 12 i/o --- r17 13 13 i/o analog input port 8 - - r20 14 - i/o --- r21 15 - i/o --- r22 16 - i/o --- r23 17 14 i/o analog input port 9 - - r24 18 15 i/o analog input port 10 - - r25 19 16 i/o analog input port 11 - - r26 20 17 i/o analog input port 12 - - r27 21 - i/o --- r30(an13) 22 23 i/o analog input port 13 - - r31 (an14) 23 24 i/o analog input port 14 - - r32 (an15) 24 18 i/o analog input port 15 - - table 5-5 pin description .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 8 mar. 2005 ver 0.2 6. port structures r13~r16,r20~r22,r27 r17,r30~r32,r23~r26(an8 ~ an15) r01 (an1 / si) r03 (an3 / int2), r07 (an7 / ec1) v dd v ss pin data reg. direction reg. pull-up tr. pull-up reg. mux v dd data bus v dd v ss open drain reg. rd rd an[15:14] aden & ads[3:0] (adcm) v dd v ss pin data reg. direction reg. pull-up tr. pull-up reg. mux v dd data bus v dd v ss open drain reg. si si_en (siom) noise filter rd an[1] aden & ads[3:0] v dd v ss pin data reg. direction reg. pull-up tr. pull-up reg. mux v dd data bus v dd v ss open drain reg. (adcm) int2, ec1 int2e (psr0.2), ec1e (psr0.5) noise filter rd an[3, 7] aden & ads[3:0] v dd v ss pin data reg. direction reg. pull-up tr. pull-up reg. mux v dd data bus v dd v ss open drain reg. (adcm) .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 9 r04 (an4 / ec0 / rxd) r11 (int0 / pwm3o), r12 (int1 / buzo) r02 (an2 / sout) r00 (int3 / sck) ec0 ec0e (psr0) noise filter rd an[1] aden & ads[3:0] v dd v ss pin data reg. direction reg. pull-up tr. pull-up reg. mux v dd data bus v dd v ss open drain reg. (adcm) rxd rxe (asimr) noise filter int0,int1 int0e(psr0.0) noise filter rd v dd v ss pin data reg. direction reg. pull-up tr. pull-up reg. mux v dd data bus v dd v ss open drain reg. int1e(psr0.1) mux pwm3oe(psr0.7) buzoe(psr1.2) pwm3o, buzo sout(si) so_out_en (siom) noise filter rd v dd v ss pin data reg. direction reg. pull-up tr. pull-up reg. mux v dd data bus v dd v ss open drain reg. mux so_en(siom) sout an[2] aden & ads[3:0] (adcm) sck sck_en(siom) noise filter rd v dd v ss pin data reg. direction reg. pull-up tr. pull-up reg. mux v dd data bus v dd v ss open drain reg. mux scko_en(siom) sck int3 int3e(psr0.3) noise filter .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 10 mar. 2005 ver 0.2 r06 (an6 / t2o / aclk) r10 (an0 / av ref / pwm1o) r05 (an5 / t0o / txd) reset an[6] aden & ads[3:0] rd v dd v ss pin data reg. direction reg. pull-up tr. pull-up reg. mux v dd data bus v dd v ss open drain reg. mux t2oe(psr1.1) t2o aclk tps[2:0](brgcr[6:4]) noise filter (adcm) an[0] aden & ads[3:0] rd v dd v ss pin data reg. direction reg. pull-up tr. pull-up reg. mux v dd data bus v dd v ss open drain reg. mux pwm1oe(psr0.6) pwm1o adc reference avrefs(psr1.3) (adcm) mux v dd voltage input an[5] aden & ads[3:0] rd v dd v ss pin data reg. direction reg. pull-up tr. pull-up reg. mux v dd data bus v dd v ss open drain reg. mux t0oe(psr1.0) txd (adcm) mux t0o txe(asimr.7) pin v dd v ss data bus mask only pull-up tr. pull-up reg. v dd rd internal reset reset disable (configuration option bit) .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 11 x in , x out (crystal or ceramic resonator) x in , x out (external rc or r oscillation) r33 (x in ), r34 (x out ) v dd v ss v dd v ss v dd v dd stop main clock x in x out x in v dd v ss x out v dd v ss v dd stop main clock f xin 4 rd v dd v ss data reg. direction reg. pull-up tr. pull-up reg. mux v dd data bus v dd v ss open drain reg. rd v dd v ss x out data reg. direction reg. pull-up tr. pull-up reg. mux v dd data bus v dd v ss open drain reg. system clock 4 in4mclkxo in2mclkco exrcxo clock option (configuration option bit) in4mclkxo in2mclkxo clock option (configuration option bit) / r34 x in / r33 main clock (to onp block) in4mclk in2mclk in4mclk in2mclk exrc .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 12 mar. 2005 ver 0.2 7. electrical ch arace teristics 7.1 absolute maximum ratings supply voltage-0.3 to +6.5 v storage temperature-65 to +150 c voltage on any pin with respect to ground (v ss ) -0.3 to v dd +0.3v maximum current out of v ss pin200 ma maximum current into v dd pin100 ma maximum current sunk by (i ol per i/o pin)20 ma maximum output current sourced by (i oh per i/o pin) 10 ma maximum current ( i ol )160 ma maximum current ( i oh )80 ma note: stresses above thos e listed under ?absolute maxi- mum ratings? may cause permanent damage to the de- vice. this is a stress rating only and functional operation of the device at any other conditions above those indicated in the operational sections of this specification is not implied. exposure to absolute maximum rating conditions for ex- tended periods may affect device reliability. 7.2 recommended operating conditions 7.3 a/d converter characteristics (t a =-40~85 c, v ss =0v, v dd =2.7~5.5v @f xin =8mhz) parameter symbol condition specifications unit min. max. supply voltage v dd f xin =0.4~12mhz f xin =0.4~8mhz 4.5 2.5 5.5 5.5 v operating frequency f xin v dd =4.5~5.5v v dd =2.7~5.5v(mc80f03xxx) v dd =2.0~5.5v(mc80c03xxx) 0.4 0.4 0.4 12 8 4.2 mhz operating temperature t opr v dd =2.7~5.5v(mc80f03xxx) v dd =2.0~5.5v(mc80c03xxx) -40 85 c parameter symbol conditions min. typ. max. unit resolution - - 10 - bit overall accuracy - - - - 3lsb integral linearity error ile v dd = av ref = 5v cpu clock = 10mhz v ss = 0v - ? 3lsb differential linearity error dle - ? 3lsb offset error of top eot - 1 3lsb offset error of bottom eob - 0.5 3lsb conversion time t conv -13-- s analog input voltage v ain - v ss - v dd (av ref ) v analog reference voltage av ref -tbd- v dd v analog input current i ain v dd = av ref = 5v --10 a .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 13 7.4 dc electrical characteristics (t a =-40~85 c, v dd =5.0v , v ss =0v) , analog block current i avdd v dd = av ref = 5v v dd = av ref = 3v - - 1 0.5 3 1.5 ma v dd = av ref = 5v power down mode - 100 500 na parameter symbol conditions min. typ. max. unit parameter symbol pin condition specifications unit min. typ. max. input high voltage v ih1 x in , reset 0.8 v dd - v dd v v ih2 hysteresis input 1 0.8 v dd - v dd v ih3 normal input 0.7 v dd - v dd input low voltage v il1 x in , reset 0- 0.2 v dd v v il2 hysteresis input 1 0- 0.2 v dd v il3 normal input 0 - 0.3 v dd output high voltage v oh all output port v dd =5v, i oh =-5ma v dd -1 --v output low voltage v ol all output port v dd =5v, i ol =10ma - -1v input pull-up current i p normal input v dd =5v -70 - -130 a input high leakage current i ih1 all pins (except x in )v dd =5v --5 a i ih2 x in v dd =5v --15 a input low leakage current i il1 all pins (except x in )v dd =5v -5 - - a i il2 x in v dd =5v -15 - - a hysteresis | v t | hysteresis input 1 v dd =5v 0.5 - - v pfd voltage v pfd v dd 2.0 - 3.0 v internal rc wdt period t rcwdt x out v dd =5.5v 36 - 90 s operating current 2 i dd v dd v dd =5.5v, f xin =8mhz -46.5 ma v dd =3.0v, f xin =4mhz -23 wake-up timer mode current i wkup v dd v dd =5.5v, f xin =8mhz -12 ma v dd =3.0v, f xin =4mhz -0.31 rcwdt mode current at stop mode i rcwdt v dd v dd =5.5v -3070 a v dd =3.0v -550 stop mode current i stop v dd v dd =5.5v, f xin =8mhz -0.53 a v dd =3.0v, f xin =4mhz -0.21 internal oscillation frequency t in_clk x out v dd =5v 345mhz .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 14 mar. 2005 ver 0.2 7.5 ac characteristics (t a =-40~+85 c, v dd =5v 10% , v ss =0v) figure 7-1 timing chart external rc oscillator frequency f rc-osc f xout = f rc-osc 4 v dd =5.5v r=30k ?, c=10pf 0.7 - 1.5 mhz f r-osc f xout = f r-osc 4 v dd =5.5v r=30k ? 2-4mhz 1. hysteresis input: int0 ~ int3(r11,r12,r03,r00),sio(r00,r01,r02),uart(r04,r06,ec0,ec1) 2. this parameter is measured in internal prom operation at the all i/o port defined input mode. parameter symbol pin condition specifications unit min. typ. max. parameter symbol pins specifications unit min. typ. max. operating frequency f cp x in 0.4 - 12 mhz external clock pulse width t cpw x in 35 - - ns external clock transition time t rcp, t fcp x in --20ns oscillation stabilizing time(4mhz) t st x in , x out --20ms external input pulse width t epw int0, int1, int2, int3 ec0, ec1 2- - t sys reset input width t rst reset 8- - t sys t rcp t fcp x in int0, int1 int2, 0.5v v dd -0.5v 0.2v dd reset 0.2v dd 0.8v dd ec0, t rst t epw t epw 1/f cp t cpw t cpw t sys int3 ec1 .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 15 7.6 typical characteristics these graphs and tables provided in this section are for de- sign guidance only and are not tested or guaranteed. in some graphs or tables the data presented are out- side specified operating ra nge (e.g. outside specified v dd range). this is for information only and devices are guaranteed to operate properly only within the specified range. the data presented in this s ection is a statistical summary of data collected on units from different lots over a period of time. ?typical? represents the mean of the distribution while ?max? or ?min? represents (mean + 3 ) and (mean ? 3 ) respectively where is standard deviation tbd .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 16 mar. 2005 ver 0.2 8. memory organization the mc80f0304/0308/0316 has separate address spaces for program memory and data memory. 4k bytes program memory can only be read, not written to. data memory can be read and written to up to 256 bytes in- cluding the stack area. 8.1 registers this device has six registers that are the program counter (pc), a accumulator (a), two index registers (x, y), the stack pointer (sp), and the program status word (psw). the program counter consis ts of 16-bit register. figure 8-1 configuration of registers accumulator: the accumulator is the 8-bit general pur- pose register, used for data op eration such as transfer, tem- porary saving, and conditional judgement, etc. the accumulator can be used as a 16-bit register with y register as shown below. figure 8-2 configuration of ya 16-bit register x, y registers : in the addressing mode which uses these index registers, the register contents are added to the spec- ified address, which becomes the actual address. these modes are extremely effectiv e for referencing subroutine tables and memory tables. the index registers also have in- crement, decrement, comparison and data transfer func- tions, and they can be used as simple accumulators. stack pointer : the stack pointer is an 8-bit register used for occurrence interrupts and calling out subroutines. stack pointer identifies the location in the stack to be accessed (save or restore). generally, sp is automatically updated when a subroutine call is executed or an interrupt is accepted. however, if it is used in excess of the stack area permitted by the data memory allocating configurat ion, the user-processed data may be lost. the stack can be located at any position within 1c0 h to 1ff h of the internal data memory. the sp is not initialized by hardware, requiring to write the initial value (the loca- tion with which the use of the stack starts) by using the in- itialization routine. normally, the initial value of ?ff h ? is used. note: the stack pointer must be initialized by software be- cause its value is undefined after reset. example: to initialize the sp ldx #0ffh txsp ; sp ffh program counter : the program counter is a 16-bit wide which consists of two 8-bit registers, pch and pcl. this counter indicates the address of the next instruction to be executed. in reset state, the program counter has reset rou- tine address (pc h :0ff h , pc l :0fe h ). program status word : the program status word (psw) contains several bits that re flect the current state of the cpu. the psw is described in figure 8-3 . it contains the negative flag, the overflow flag, the break flag the half carry (for bcd operation), the interrupt enable flag, the zero flag, and the carry flag. [carry flag c] this flag stores any carry or borrow from the alu of cpu after an arithmetic operation and is also changed by the shift instruction or rotate instruction. [zero flag z] this flag is set when the result of an arithmetic operation or data transfer is ?0? and is cleared by any other result. accumulator x register y register stack pointer program counter program status word x a sp y pcl psw pch two 8-bit registers can be used as a ?ya? 16-bit register y a y a sp 01 h stack address (1c0 h ~ 1ff h ) bit 15 bit 0 87 hardware fixed c0 h ~ff h .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 17 figure 8-3 psw (program status word) register [interrupt disable flag i] this flag enables/disables all interrupts except interrupt caused by reset or software brk instruction. all inter- rupts are disabled when cleared to ?0?. this flag immedi- ately becomes ?0? when an inte rrupt is served. it is set by the ei instruction and cleared by the di instruction. [half carry flag h] after operation, this is set wh en there is a carry from bit 3 of alu or there is no borrow from bit 4 of alu. this bit can not be set or cleared except clrv instruction with overflow flag (v). [break flag b] this flag is set by software brk instruction to distinguish brk from tcall instruction with the same vector ad- dress. [direct page flag g] this flag assigns ram page for direct addressing mode. in the direct addressing mode, addressing area is from zero page 00 h to 0ff h when this flag is "0". if it is set to "1", addressing area is assigned 100 h to 1ff h . it is set by setg instruction and cleared by clrg. [overflow flag v] this flag is set to ?1? when an overflow occurs as the result of an arithmetic operation involving signs. an overflow occurs when the result of an addition or subtraction ex- ceeds +127(7f h ) or -128(80 h ). the clrv instruction clears the overflow flag. there is no set instruction. when the bit instruction is executed, bit 6 of memory is copied to this flag. [negative flag n] this flag is set to match the sign bit (bit 7) status of the re- sult of a data or arithmetic operation. when the bit in- struction is executed, bit 7 of memory is copied to this flag. n negative flag v g b h i z c msb lsb reset value: 00 h psw overflow flag brk flag carry flag receives zero flag interrupt enable flag carry out half carry fl ag receives carry out from bit 1 of addition operlands select direct page when g=1, page is selected to ?page 1? .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 18 mar. 2005 ver 0.2 figure 8-4 stack operation at execution of a call/tcall/pcall pcl pch 01fc sp after execution sp before execution 01fd 01fd 01fe 01ff 01ff push down at acceptance of interrupt pcl pch 01fc 01fc 01fd 01fe 01ff 01ff push down psw at execution of ret instruction pcl pch 01fc 01ff 01fd 01fe 01ff 01fd pop up at execution of ret instruction pcl pch 01fc 01ff 01fd 01fe 01ff 01fc pop up psw 01c0h 01ffh stack depth at execution of push instruction a 01fc 01fe 01fd 01fe 01ff 01ff push down sp after execution sp before execution push a (x,y,psw) at execution of pop instruction a 01fc 01ff 01fd 01fe 01ff 01fe pop up pop a (x,y,psw) .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 19 8.2 program memory a 16-bit program counter is capable of addressing up to 64k bytes, but this device has 4k/8k/16k bytes program memory space only physically implemented. accessing a location above ffff h will cause a wrap-around to 0000 h . figure 8-5 , shows a map of program memory. after reset, the cpu begins execution from reset vector which is stored in address fffe h and ffff h as shown in figure 8-6 . as shown in figure 8-5 , each area is assigned a fixed lo- cation in program memory. program memory area con- tains the user program figure 8-5 program memory map page call (pcall) area cont ains subroutine program to reduce program byte length by using 2 bytes pcall in- stead of 3 bytes call instructio n. if it is frequently called, it is more useful to save program byte length. table call (tcall) causes the cpu to jump to each tcall address, where it comm ences the execution of the service routine. the table call service area spaces 2-byte for every tcall: 0ffc0 h for tcall15, 0ffc2 h for tcall14, etc., as shown in figure 8-7 . example: usage of tcall the interrupt causes the cpu to jump to specific location, where it commences the executi on of the service routine. the external interrupt 0, for example, is assigned to loca- tion 0fffc h . the interrupt service locations spaces 2-byte interval: 0fffa h and 0fffb h for external interrupt 1, 0fffc h and 0fffd h for external interrupt 0, etc. any area from 0ff00 h to 0ffff h , if it is not going to be used, its service location is available as general purpose program memory. interrupt vector area feff h ff00 h ffc0 h ffdf h ffe0 h ffff h pcall area c000 h tcall area 8k rom 4k rom 16k rom e000 h f000 h lda #5 tcall 0fh ; 1byte instruction :; instead of 3 bytes :; normal call ; ;table call routine ; func_a: lda lrg0 ret ; func_b: lda lrg1 ret ; ;table call add. area ; org 0ffc0h ; tcall address area dw func_a dw func_b 1 2 0ffe0 h e2 address vector area memory e4 e6 e8 ea ec ee f0 f2 f4 f6 f8 fa fc fe basic interval timer watchdog timer interrupt a/d converter - external interrupt 3 serial input/output (sio) external interrupt 1 external interrupt 0 reset external interrupt 2 timer/counter 3 interrupt timer/counter 0 interrupt uart rx interrupt uart tx interrupt timer/counter 1 interrupt timer/counter 2 interrupt .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 20 mar. 2005 ver 0.2 figure 8-6 interrupt vector area figure 8-7 pcall and tcall memory area pcall rel 4f35 pcall 35h tcall n 4a tcall 4 example: the usage software example of vector address 0ffc0 h c1 address program memory c2 c3 c4 c5 c6 c7 c8 0ff00 h address pcall area memory 0ffff h pcall area (256 bytes) * means that the brk software interrupt is using same address with tcall0. note: tcall 15 tcall 14 tcall 13 tcall 12 tcall 11 tcall 10 tcall 9 tcall 8 tcall 7 tcall 6 tcall 5 tcall 4 tcall 3 tcall 2 tcall 1 tcall 0 / brk * c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df 4f ~ ~ ~ ~ next 35 0ff35 h 0ff00 h 0ffff h 11111111 11010110 01001010 pc: fh fh dh 6h 4a ~ ~ ~ ~ 25 0ffd6 h 0ff00 h 0ffff h d1 next 0ffd7 h ? ? ? 0d125 h reverse .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 21 8.3 data memory figure 8-1 shows the intern al data memory space availa- ble. data memory is divided into three groups, a user ram, control register s, and stack memory. figure 8-1 data memory map user memory the mc80f0304/0308/0316 has 256 8 bits for the user memory (ram). ram pages are selected by rpr (see figure 8-2 ). note: after setting rpr(ram page select register), be sure to execute setg instru ction. when executing clrg instruction, be selected page0 regardless of rpr. control registers the control registers are us ed by the cpu and peripheral function blocks for controlling the desired operation of the device. therefore these regist ers contain control and status bits for the interrupt system, the timer/ counters, analog to digital converters and i/o ports. the control registers are in address range of 0c0 h to 0ff h . note that unoccupied addre sses may not be implemented on the chip. read accesses to th ese addresses will in gen- eral return random data, and write accesses will have an in- determinate effect. more detailed informations of each register are explained in each peripheral section. note: write only registers can not be accessed by bit ma- nipulation instruction. do not use read-modify-write instruc- tion. use byte manipulation instruction, for example ?ldm?. example; to wr ite at ckctlr ldm ckctlr,#0ah ;divide ratio( 32) stack area the stack provides the area where the return address is saved before a jump is perfo rmed during the processing routine at the execu tion of a subroutine call instruction or the acceptance of an interrupt. when returning from the pro cessing routine, executing the subroutine return instruction [r et] restores the contents of the program counter from the stack; executing the interrupt return instruction [reti] restor es the contents of the pro- gram counter and flags. the save/restore locations in the stack are determined by the stack pointed (sp). the sp is automatically decreased after the saving, and increased before the restoring. this means the value of the sp indicates the stack location number for the next save. refer to figure 8-4 on page 18. figure 8-2 rpr(ram page select register) user memory control registers 0000 h 00bf h 00c0 h page0 page1 (when ?g-flag=0?, this page0 is selected) user memory 00ff h 0100 h 023f h (192bytes) (64bytes) 01ff h 0200 h user memory stack area page2 system clock source select 000 : page0 001 : page1 initial value: ---- -000 b address: 0e1 h rpr 010 : page2 011 : not used - 76543210 - - r/w r/w r/w rpr2 -- rpr1 rpr0 100 : not used - others : setting prohibited .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 22 mar. 2005 ver 0.2 address register name symbol r/w initial value addressing mode 76543210 00c0 r0 port data register r0 r/w 00000000 byte, bit 1 00c1 r0 port i/o direction register r0io w 00000000 byte 2 00c2 r1 port data register r1 r/w 00000000 byte, bit 00c3 r1 port i/o direction register r1io w 00000000 byte 00c4 r2 port data register r2 r/w 00000000 byte, bit 00c5 r2 port i/o direction register r2io w 00000000 byte 00c6 r3 port data register r3 r/w - - - 0 0 0 0 0 byte, bit 00c7 r3 port i/o direction register r3io w - - - 0 0 0 0 0 byte 00c8 port 0 open drain selection register r0od r/w 00000000 byte, bit 00c9 port 1 open drain selection register r1od w 00000000 byte 00ca port 2 open drain selection register r2od w 00000000 byte 00cb port 3 open drain selection register r3od w - - - 0 0 0 0 0 byte 00d0 timer 0 mode control register tm0 r/w - - 000000 byte, bit 00d1 timer 0 register t0 r 00000000 byte timer 0 data register tdr0 w 11111111 timer 0 capture data register cdr0 r 0 0 000000 00d2 timer 1 mode control register tm1 r/w 00000000 byte, bit 00d3 timer 1 data register tdr1 w 11111111 byte timer 1 pwm period register t1ppr w 11111111 byte 00d4 timer 1 register t1 r 00000000 byte timer 1 capture data register cdr1 r 0 0 000000 timer 1 pwm duty register t1pdr r/w 00000000 byte 00d5 timer 1 pwm high register t1pwhr w - - - - 0 0 0 0 bit 00d6 timer 2 mode control register tm2 r/w - - 000000 byte, bit 00d7 timer 2 register t2 r 00000000 byte timer 2 data register tdr2 w 11111111 timer 2 capture data register cdr2 r 0 0 000000 00d8 timer 3 mode control register tm3 r/w 00000000 byte, bit 00d9 timer 3 data register tdr3 w 11111111 byte timer 3 pwm period register t3ppr w 11111111 table 8-1 control registers .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 23 00da timer 3 register t3 r 00000000 byte timer 3 pwm duty register t3pdr r/w 00000000 timer 3 capture data register cdr3 r 0 0 000000 00db timer 3 pwm high register t3pwhr w - - - - 0 0 0 0 byte 00e0 buzzer driver register buzr w 11111111 byte 00e1 ram page selection register rpr r/w -----000 byte, bit 00e2 sio mode control register siom r/w 00000001 byte, bit 00e3 sio data shift register sior r/w undefined byte, bit 00e6 uart mode register asimr r/w 0 0 0 0 - 0 0 - byte, bit 00e7 uart status register asisr r -----000 byte 00e8 uart baud rate generator control register brgcr r/w - 0 010000 byte, bit 00e9 uart receive buffer register rxbr r 00000000 byte uart transmit shift register txsr w 11111111 00ea interrupt enable register high ienh r/w 00000000 byte, bit 00eb interrupt enable register low ienl r/w 00000000 byte, bit 00ec interrupt request register high irqh r/w 0 0 000000 byte, bit 00ed interrupt request register low irql r/w 0 0 000000 byte, bit 00ee interrupt edge selection register ieds r/w 00000000 byte, bit 00ef a/d converter mode control register adcm r/w 00000001 byte, bit 00f0 a/d converter result high register adcrh r(w) 0 1 0 undefined byte 00f1 a/d converter result lo w register adcrl r undefined byte 00f2 basic interval timer register bitr r undefined byte clock control register ckctlr w 0 - 010111 00f4 watch dog timer register wdtr w 01111111 byte watch dog timer data register wdtdr r undefined 00f5 stop & sleep mode control register sscr w 00000000 byte 00f7 pfd control register pfdr r/w -----000 byte, bit 00f8 port selection register 0 psr0 w 00000000 byte 00f9 port selection register 1 psr1 w - - - - 0 0 0 0 byte 00fc pull-up selection register 0 pu0 w 00000000 byte 00fd pull-up selection register 1 pu1 w 00000000 byte 00fd pull-up selection register 2 pu2 w 00000000 byte 00ff pull-up selection register 3 pu3 w - - 000000 byte address register name symbol r/w initial value addressing mode 76543210 table 8-1 control registers .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 24 mar. 2005 ver 0.2 the ?byte? means registers are controlled by only byte manipulation instruction. do not use bit manipulation 1. the ?byte, bit? means registers are controll ed by both bit and byte m anipulation instruction. 2. instruction such as set1, clr1 etc. if bit m anipulation instruction is used on these registers, content of other seven bits are may varied to unwanted value. *the mark of ?-? means this bit location is reserved. caution) the r/w register except t1pdr a nd t3pdr are both can be byte and bit manipulated. address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0c0h r0 r0 port data register 0c1h r0io r0 port direction register 0c2h r1 r1 port data register 0c3h r1io r1 port direction register 0c4h r2 r2 port data register 0c5h r2io r2port data register 0c6h r3 r3 port data register 0c7h r3io r3 port direction register 0c8h r0od r0 open drain selection register 0c9h r1od r1 open drain selection register 0cah r2od r2 open drain selection register 0cbh r3od r3 open drain selection register 0d0h tm0 - - cap0 t0ck2 t0ck1 t0ck0 t0cn t0st 0d1h t0/tdr0/ cdr0 timer0 register / timer0 data register / timer0 capture data register 0d2h tm1 pol 16bit pwm1e cap1 t1ck1 t1ck0 t1cn t1st 0d3h tdr1/ t1ppr timer1 data register / ti mer1 pwm period register 0d4h t1/cdr1 timer1 register / timer1 capture data register 0d5h pwm1hr - - - - timer1 pwm high register 0d6h tm2 - - cap2 t2ck2 t2ck1 t2ck0 t2cn t2st 0d7h t2/tdr2/ cdr2 timer2 register / timer2 data register / timer2 capture data register 0d8h tm3 pol 16bit pwm3e cap3 t3ck1 t3ck0 t3cn t3st 0d9h tdr3/ t3ppr timer3 data register / ti mer3 pwm period register 0dah t3/cdr3/ t3pdr timer3 register / timer3 capture data register / timer3 pwm duty register 0dbh pwm3hr - - - - timer3 pwm high register 0e0h buzr buck1 buck0 bur5 bur4 bur3 bur2 bur1 bur0 0e1h rpr - - - - - rpr2 rpr1 rpr0 0e2h siom pol iosw sm1 sm0 sck1 sck0 siost siosf table 8-2 control register function description .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 25 0e3h sior sio data shift register 0e6h asimr txe0 rxe0 ps01 ps00 - sl0 isrm0 - 0e7h asisr - - - - - pe0 fe0 ove0 0e8h brgcr0 - tps02 tps01 tps00 mld03 mld02 mld01 mld00 0e9h rxr uart receive buffer register txr uart transmit shift register 0eah ienh int0e int1e int2e int3e rxe txe sioe t0e 0ebh ienl t1e t2e t3e t4e adce wdte wte bite 0ech irqh int0if int1if int2if int3if rxif txif sioif t0if 0edh irql t1if t2if t3if t4if adcif wdtif wtif bitif 0eeh ieds ied3h ied3l ied2h ied2l ied1h ied1l ied0h ied0l 0efh adcm aden adck ads3 ads2 ads1 ads0 adst adsf 0f0h adcrh pssel1 pssel0 adc8 - - - adc result reg. high 0f1h adcrl adc result register low 0f2h bitr 1 basic interval timer data register ckctlr 1 adrst - rcwdt wdton btcl bts2 bts1 bts0 0f4h wdtr wdtcl 7-bit watchdog timer register wdtdr watchdog timer data register (counter register) 0f5h sscr stop & sleep mode control register 0f7h pfdr - - - - - pfden pfdm pfds 0f8h psr0 pwm3o pwm1o ec1e ec0e int3e int2e int1e int0e 0f9h psr1 - - - - xten buzo t2o t0o 0fch pu0 r0 pull-up selection register 0fdh pu1 r1 pull-up selection register 0feh pu2 r2 pull-up selection register 0ffh pu3 r3 pull-up selection register 1. the register bitr and ckctlr are located at same ad dress. address ech is read as bitr, written to ckctlr. caution) the registers of dark-shaded area can not be accessed by bit manipulation instruction such as "set1, clr1", but should be accessed by register operation instruction such as "ldm dp,#imm". address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 table 8-2 control register function description .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 26 mar. 2005 ver 0.2 8.4 addressing mode the mc8 series mcu uses six addressing modes; ? register addressing ? immediate addressing ? direct page addressing ? absolute addressing ? indexed addressing ? register-indirect addressing 8.4.1 register addressing register addressing accesses the a, x, y, c and psw. 8.4.2 immediate addressing #imm in this mode, second byte (o perand) is accessed as a data immediately. example: 0435 adc #35h when g-flag is 1, then ram address is defined by 16-bit address which is composed of 8-bit ram paging register (rpr) and 8-bit immediate data. example: g=1 e45535 ldm 35h,#55h 8.4.3 direct page addressing dp in this mode, a address is sp ecified within direct page. example; g=0 c535 lda 35h ;a ram[35h] 8.4.4 absolute addressing !abs absolute addressing sets co rresponding memory data to data, i.e. second byte (ope rand i) of command becomes lower level address and thir d byte (operand ii) becomes upper level address. with 3 bytes command, it is possible to access to whole memory area. adc, and, cmp, cmpx, cmpy, eor, lda, ldx, ldy, or, sbc, sta, stx, sty example; 0735f0 adc !0f035h ;a rom[0f035h] the operation within data memory (ram) asl, bit, dec, inc, lsr, rol, ror example; addressing accesses the address 0135 h regard- less of g-flag. 35 a+35h+c a 04 memory e4 0f100h data 55h ~ ~ ~ ~ data 0135h ? 35 0f102h 55 0f101h ? data 35 35h 0e551h data a ? ? ~ ~ ~ ~ c5 0e550h 07 0f100h ~ ~ ~ ~ data 0f035h ? f0 0f102h 35 0f101h ? a+data+c a address: 0f035 .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 27 983501 inc !0135h ;a rom[135h] 8.4.5 indexed addressing x indexed direct page (no offset) {x} in this mode, a address is specified by the x register. adc, and, cmp, eor, lda, or, sbc, sta, xma example; x=15 h , g=1 d4 lda {x} ;acc ram[x]. x indexed direct page, auto increment {x}+ in this mode, a address is sp ecified within direct page by the x register and the content of x is increased by 1. lda, sta example; g=0, x=35 h db lda {x}+ x indexed direct page (8 bit offset) dp+x this address value is the second byte (operand) of com- mand plus the data of x -register. and it assigns the mem- ory in direct page. adc, and, cmp, eor, lda, ldy, or, sbc, sta sty, xma, asl, dec, inc, lsr, rol, ror example; g=0, x=0f5 h c645 lda 45h+x y indexed direct page (8 bit offset) dp+y this address value is the second byte (operand) of com- mand plus the data of y-register, which assigns memory in direct page. this is same with above (2). use y register instead of x. y indexed absolute !abs+y sets the value of 16-bit absolute address plus y-register data as memory.this addressi ng mode can specify memo- ry in whole area. example; y=55 h 98 0f100h ~ ~ ~ ~ data 135h ? 01 0f102h 35 0f101h ? data+1 data ? address: 0135 data d4 115h 0e550h data a ? ? ~ ~ ~ ~ data db 35h data a ? ? ~ ~ ~ ~ 36h x data 45 3ah 0e551h data a ? ? ~ ~ ~ ~ c6 0e550h 45h+0f5h=13ah ? .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 28 mar. 2005 ver 0.2 d500fa lda !0fa00h+y 8.4.6 indirect addressing direct page indirect [dp] assigns data address to us e for accomplishing command which sets memory data (or pair memory) by operand. also index can be used with index register x,y. jmp, call example; g=0 3f35 jmp [35h] x indexed indirect [dp+x] processes memory data as data, assigned by 16-bit pair memory which is determined by pair data [dp+x+1][dp+x] operand plus x-register data in direct page. adc, and, cmp, eor, lda, or, sbc, sta example; g=0, x=10 h 1625 adc [25h+x] y indexed indirect [dp]+y processes memory data as data, assigned by the data [dp+1][dp] of 16-bit pair memory paired by operand in di- rect page plus y-register data. adc, and, cmp, eor, lda, or, sbc, sta example; g=0, y=10 h 1725 adc [25h]+y absolute indirect [!abs] the program jumps to address specified by 16-bit absolute address. jmp example; g=0 d5 0f100h data a ? ~ ~ ~ ~ data 0fa55h 0fa00h+55h=0fa55h ? fa 0f102h 00 0f101h ? 0a 35h jump to ? ~ ~ ~ ~ 35 0fa00h e3 36h ? 3f 0e30ah next ~ ~ ~ ~ address 0e30ah 05 35h 0e005h ~ ~ ~ ~ 25 0fa00h e0 36h 16 0e005h data ~ ~ ~ ~ ? a + data + c a 25 + x(10) = 35h ? ? 05 25h 0e005h + y(10) ? ~ ~ ~ ~ 25 0fa00h e0 26h ? 17 0e015h data ~ ~ ~ ~ ? = 0e015h a + data + c a .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 29 1f25e0 jmp [!0c025h] 25 0e025h jump to ~ ~ ~ ~ e0 0fa00h e7 0e026h ? 25 0e725h next ~ ~ ~ ~ 1f program memory ? address 0e30ah .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 30 mar. 2005 ver 0.2 9. i/o ports the hms83f012/022 has three ports (r0, r1 and r3). these ports pins may be multiplexed with an alternate function for the peripheral features on the device. all port can drive maximum 20ma of high current in output low state, so it can direc tly drive led device. all pins have data direction registers which can define these ports as output or input. a ?1? in the port direction register configure the corresponding port pin as output. conversely, write ?0? to the corresponding bit to specify it as input pin. for example, to use the even numbered bit of r0 as output ports and the odd numbered bits as input ports, write ?55 h ? to address 0c1 h (r0 port direction reg- ister) during initial setting as shown in figure 9-1 . all the port direction registers in the hms83f012/022 have 0 written to them by reset function. on the other hand, its initial status is input. figure 9-1 example of port i/o assignment 9.1 r0 and r0io register r0 is an 8-bit cmos bidi rectional i/o port (address 0c0 h ). each i/o pin can independently used as an input or an output through the r0io register (address 0c1 h ). when r00 through r07 pins are used as input ports, an on-chip pull-up resistor can be connected to them in 1-bit units with a pull-up selection register 0 (pu0). each i/o pin of r0 port can be used to open drain output port by setting the corresponding bit of the open drain selection register 0 (r0od). i: input port write ?55 h ? to port r0 direction register 0 1 0 1 0 1 0 1 i o i o i o i o r0 data r1 data r0 direction r1 direction 0c0 h 0c1 h 0c2 h 0c3 h 76543210 bit 76543210 port o: output port r0 data register r0 address: 0c0 h reset value: 00 h r07 r06 r05 r04 r03 r02 r01 r00 port direction r0 direction register r0io address: 0c1 h reset value: 00 h 0: input 1: output input / output data r0 pull-up pu0 address: 0fc h reset value: 00 h selection register 0: disable 1: enable pull-up resister selection r0 open drain r0od address: 0c8 h reset value: 00 h selection register 0: disable 1: enable open drain resister selection psr0 address: 0f8 h reset value: 0000 0000 b int2e port / int selection 0: r11, r12, r03, r00 1: int0, int1,int2, int3 int0e int1e int3e pwm3oe ec0e ec1e port / ec selection 0: r04, r07 1: ec0, ec1 port / pwm selection 0: r10, r11 1: pwm1o, pwm3o pwm1oe psr1 address: 0f9 h reset value: ---- 0000 b buzoe r12/buzo selection 0: r12 port (turn off buzzer) 1: buzo port (turn on buzzer) t0oe t2oe avrefs - - - - port / to selection 0: r04, r07 1: ec0, ec1 r10 / av ref selection 0: r10 port 1: av ref port .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 31 figure 9-2 r0 port register in addition, port r0 is multiplexed with various alternate functions. the port selection register psr0 (address 0f8 h ) and psr1 (address 0f9 h ) control the selection of alternate functions such as external in terrupt 3 (int3), external in- terrupt 2 (int2), event counter input 0 (ec0), timer 0 out- put (t0o), timer 2 output (t2o) and event counter input 1 (ec1). when the alternate fu nction is selected by writing ?1? in the corresponding bit of psr0 or psr1, port pin can be used as a corresponding al ternate features regardless of the direction register r0io. the adc input channel 1~7 (an1~an7), sio data input (si), sio data output (sout) and uart data input (rxd), uart data output (txd) and uart clock input (aclk) can be selected by setting adcm(00ef h ), si- om(00e2 h ) and asimr(00e6 h ) register to enable the corresponding peripheral oper ation and select operation mode. 9.2 r1 and r1io register r1 is a 5-bit cmos bidirectional i/o port (address 0c2 h ). each i/o pin can independently used as an input or an out- put through the r1io register (address 0c3 h ). when r10 through r17 pins are used as input ports, an on-chip pull- up resistor can be connected to them in 1-bit units with a pull-up selection register 1 (pu1). each i/o pin of r1 port can be used to open drain output port by setting the corre- sponding bit of the open drain selection register 1 (r1od). in addition, port r1 is multiplexed with various alternate functions. the port selection register psr0 (address 0f8 h ) and psr1 (address 0f9 h ) control the selection of alternate functions such as analog reference voltage input (avref), external interrupt 0 (int0), external interrupt 1 (int1), pwm 1 output (pwm1o), pwm 3 output (pwm3o) and buzzer output (b uzo). when the alternate function is selected by writing ?1? in the corresponding bit of psr0 or psr1, port pin can be used as a corresponding alternate features regardless of the direction register r1io. the adc input channel 0 ( an0) and channel 8(an8) can be selected by setting adcm(00ef h ) register to enable adc and select channel 0 and channel 8 . port pin alternate function r00- r01 r02 r03 r04 r05 r06 r07 int3 (external interrupt 3) sck (sio clock input/output) an1(adc input channel 1) si (sio data input)i an2 (adc input channel 2) sout (sio data output) an3 (adc input channel 3) int2 (external interrupt 2) an4 (adc input channel 4) ec0 (event counter input 0) rxd (uart data input) an5 (adc input channel 5) t0o (timer output 0) txd (uart data output) an6 (adc input channel 6) t2o (timer output 2) aclk (uart clock input) an7 (adc input channel 7) ec1 (event counter input 1) port pin alternate function r10 r11 r12 r13 r14 r15 r16 r17 an0 (adc input channel 0) avref (analog reference voltage) pwm1o (pwm 1 output) int0 (external interrupt 0) pwm3o (pwm 3 output) int1 (external interrupt 1) buzo (buzzer output) - - - - an8 .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 32 mar. 2005 ver 0.2 figure 9-3 r1 port register r1 data register r1 address: 0c2 h reset value: 00 h r17 r16 r15 r14 r13 r12 r11 r10 port direction r1 direction register r1io address: 0c3 h reset value: 00 h 0: input 1: output input / output data r1 pull-up pu1 address: 0fd h reset value: 00 h selection register 0: disable 1: enable pull-up resister selection r1 open drain r1od address: 0c9 h reset value: 00 h selection register 0: disable 1: enable open drain resister selection psr0 address: 0f8 h reset value: 0000 0000 b int2e port / int selection 0: r11, r12, r03, r00 1: int0, int1,int2, int3 int0e int1e int3e pwm3oe ec0e ec1e port / ec selection 0: r04, r07 1: ec0, ec1 port / pwm selection 0: r10, r11 1: pwm1o, pwm3o pwm1oe psr1 address: 0f9 h reset value: ---- 0000 b buzoe r12/buzo selection 0: r12 port (turn off buzzer) 1: buzo port (turn on buzzer) t0oe t2oe avrefs - - - - port / to selection 0: r04, r07 1: ec0, ec1 r10 / avref selection 0: r10 port 1: avref port .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 33 9.3 r2 and r2io register r2 is an 8-bit cmos bidi rectional i/o port (address 0c4 h ). each i/o pin can indepe ndently used as an input or an output through the r3io register (address 0c5 h ). when r20 through r27 pins are used as input ports, an on- chip pull-up resistor can be connected to them in 1-bit units with a pull-up selection register 2 (pu2). r20 through r27 pins can be used to open drain output port by setting the corresponding bit of the open drain selection register 2 (r2od). in addition, port r2 is multiplexed with alternate func- tions. r23 r24,r25,and r26 can be used as adc input channel 9 to 12 by setting adcm to enable adc and se- lect channel 9 to 12. port pin alternate function r20 r21 r22 r23 r24 r25 r26 r27 - - - an9 (adc input channel 9) an10 (adc input channel 10) an11 (adc input channel 11) an12 (adc input channel 12) - r2 data register r2 address: 0c4 h reset value: 00 h r25 r24 r23 r22 r21 port direction r2 direction register r2io address: 0c5 h reset value: 00 h 0: input 1: output input / output data r2 pull-up pu2 address: 0fe h reset value: 00 h selection register 0: disable 1: enable pull-up resister selection r2 open drain r2od address: 0ca h reset value: 00 h selection register 0: disable 1: enable open drain resister selection r27 r26 r20 .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 34 mar. 2005 ver 0.2 9.4 r3 and r3io register r3 is a 6-bit cmos bidirectional i/o port (address 0c6 h ). each i/o pin (except r35) can independently used as an in- put or an output through the r3io register (address 0c7 h ). r35 is an input only port. when r30 through r35 pins are used as input ports, an on-chip pull-up resistor can be con- nected to them in 1-bit units with a pull-up selection regis- ter 3 (pu3). r30 through r34 pins can be used to open drain output port by setting the corresponding bit of the open drain selection register 1 (r3od). in addition, port r3 is multiplexed with alternate func- tions. r30 r31,and r32 can be used as adc input channel 13,14 and 15 by setting adcm to enable adc and select channel 13,14 and 15. r33, r34 and r35 is multiplexd with x in , x out , and re- set pin . port pin alternate function r30 r31 r32 an13 (adc input channel 13) an14 (adc input channel 14) an15 (adc input channel 15) r3 data register r3 address: 0c6 h reset value: 00 h - -r35r34r33 r32 r31 r30 port direction r3 direction register r3io address: 0c7 h reset value: 00 h 0: input 1: output input / output data - - - input data r3 pull-up pu3 address: 0fd h reset value: 00 h selection register 0: disable 1: enable pull-up resister selection - - r3 open drain r3od address: 0cb h reset value: ---0 000- b selection register 0: disable 1: enable open drain resister selection .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 35 10. clock generator as shown in figure 10-1 , the clock generator produces the basic clock pulses which provide the system clock to be supplied to the cpu and the peripheral hardware. it con- tains main-frequency clock oscillator. the system clock operation can be easily obtained by attaching a crystal or a ceramic resonator between the x in and x out pin, respec- tively. the system clock can al so be obtained from the ex- ternal oscillator. in this case, it is necessary to input a external clock signal to the x in pin and open the x out pin. there are no requirements on th e duty cycle of the external clock signal, since the input to the internal clocking circuit- ry is through a divide-by-two flip-flop, but minimum and maximum high and low times specified on the data sheet must be observed. to the peripheral block, the clock among the not-divided original clock, clocks divided by 1, 2 , 4, ..., up to 4096 can be provided. peripheral clock is enabled or disabled by stop instruction. the peripheral clock is controlled by clock control register (ckc tlr). see "11. basic in- terval timer" on page 37 for details. figure 10-1 block diagram of clock generator 10.1 oscillation circuit x in and x out are the input and output, respectively, a in- verting amplifier which can be set for use as an on-chip os- cillator, as shown in figure 10-2 . figure 10-2 oscillator connections note: when using a system clock oscillator, carry out wiring in the broken line area in figure 10-2 to prevent any effects from wir- ing capacities. - minimize the wiring length. - do not allow wiring to intersec t with other signal conductors. - do not allow wiring to come near changing high current. - set the potential of the grounding position of the oscillator capac- itor to that of v ss . do not ground to any ground pattern where high current is present. - do not fetch signals from the oscillator. internal prescaler 1 peripheral clock 2 4 8 16 128 256 512 1024 32 64 ps0 ps1 ps2 ps3 ps4 ps5 ps6 ps7 ps8 ps9 ps10 f ex (hz) ps0 ps3 ps2 ps4 ps1 ps10 ps9 ps5 ps6 ps7 4m frequency period 4m 1m 500k 250k 2m 125k 62.5k 250n 500n 1u 2u 4u 8u 16u 32u 64u 256u 128u 3.906k 7.183k 15.63k 31.25k ps8 2048 4096 ps12 ps11 1.953k 976 512u 1.024m main osc sleep f ex system clock ps12 ps11 x in clock pulse generator ( 2) stop osc circuit x out stop inosc onp circuit mux inosc f xin inclk int osc circuit inosc inosc (in4mclk/in2mclk/ 7 ~ 3 2 ~ 0 configuration option register (20ff h ) in4mclkxo/in2mclkxo) xout xin vss c1 c2 .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 36 mar. 2005 ver 0.2 n addition, see figure 10-3 for the layout of the crystal. figure 10-3 layout of oscillator pcb circuit to drive the device from an external clock source, xout should be left unconnected while xin is driven as shown in figure 10-4 . there are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum high and low times specified on the data sheet must be observed. oscillation circuit is designed to be used either with a ce- ramic resonator or crystal oscillator. since each crystal and ceramic resonator have their own characteristics, the user should consult the crystal manufacturer for appropriate values of external components. figure 10-4 external clock connections in addition, the hms83f012/022 has an ability for the ex- ternal rc oscillated operation. it offers additional cost sav- ings for timing insensitive applications . the rc oscillator frequency is a function of the supply voltage, the external resistor (r ext ) and capacitor (c ext ) values, and the operating temperature. the user needs to take into account variation due to toler- ance of external r and c components used. figure 10-5 shows how the rc combination is connected to the hms83f012/022. external capacitor (c ext ) can be omitted for more cost saving . however, the characteristics of external r only oscillation are more variable than exter- nal rc oscillation. figure 10-5 rc oscillator connections figure 10-6 r oscillator connections to use the rc oscillation , the clk option of the configu- ration bits (20ff h ) should be set to ?exrc or exrcxo?. the oscillator frequency, divi ded by 4, is output from the xout pin, and can be used for test purpose or to synchro- nize other logic. in addition to extern al crystal/resonator and external rc/r oscillation, the hms83f012/022 provides the internal 4mhz or 2mhz oscillation. the internal 4mhz/2mhz os- cillation needs no external parts. to use the internal 4mhz/2mhz oscillation, the clk op- tion of the configuration bits should be set to ?in4mclk?, ?in2mclk?, ?in4mclkxo? or ?in2mclkxo?. for detail description on the configuration bits, refer to "23.. device configuration area" on page 100 x out x in xout xin vss open external clock source x out x in vdd c ext f xin 4 r ext cint 6pf x out x in v dd f xin 4 r ext c int 6pf .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 37 11. basic interval timer the hms83f012/022 has one 8-bit basic interval timer that is free-run and can not stop. block diagram is shown in figure 11-1 . in addition, the basic interval timer gen- erates the time base for wa tchdog timer counting. it also provides a basic interval timer interrupt (bitif). the 8-bit basic interval timer register (bitr) is increased every internal count pulse wh ich is divided by prescaler. since prescaler has divided ratio by 8 to 1024, the count rate is 1/8 to 1/1024 of the oscillator frequency. as the count overflow from ffh to 00h, this overflow causes the interrupt to be generated. the basic interval timer is co ntrolled by the clock control register (ckctlr) shown in figure 11-2. if the rcwdt bit is set to ?1?, the clock so urce of the bitr is changed to the internal rc oscillation. when write "1" to bit btcl of ckctlr, bitr register is cleared to "0" and restart to count-up. the bit btcl be- comes "0" after one mach ine cycle by hardware. if the stop instruction execut ed after writing "1" to bit rcwdt of ckctlr, it goes into the internal rc oscillat- ed watchdog timer mode. in this mode, all of the block is halted except the internal rc oscillator, basic interval timer and watchdog timer. more detail informations are explained in power saving function. the bit wdton de- cides watchdog timer or the normal 7-bit timer. source clock can be selected by lower 3 bits of ckctlr. bitr and ckctlr are located at same address, and ad- dress 0f2 h is read as a bitr, and written to ckctlr. note: all control bits of basic interval timer are in ckctlr reg- ister which is located at same address of bitr (address ec h ). ad- dress ec h is read as bitr, written to ckctlr. therefore, the ckctlr can not be accessed by bit manipulation instruction. figure 11-1 block diagram of basic interval timer mux basic interval bitr select input clock 3 basic interval timer source clock 8-bit up-counter bck[2:0] btcl 1024 512 256 128 64 32 16 8 to watchdog timer (wdtck) ckctlr clear overflow internal bus line clock control register [0f2 h ] [0f2 h ] bitif read x in pin prescaler timer interrupt internal rc osc rcwdt 1 0 rcwdt .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 38 mar. 2005 ver 0.2 table 11-1 basic interval timer interrupt period figure 11-2 bitr: basic in terval timer mode register example 1: interrupt request flag is generated every 8.192ms at 4mhz. : ldm ckctlr,#1bh set1 bite ei : example 2: interrupt request flag is generated every 8.192ms at 8mhz. : ldm ckctlr,#1ch set1 bite ei : ckctlr [2:0] source clock interrupt (overflow) period (ms) @ f xin = 8mhz 000 001 010 011 100 101 110 111 f xin 8 f xin 16 f xin 32 f xin 64 f xin 128 f xin 256 f xin 512 f xin 1024 0.256 0.512 1.024 2.048 4.096 8.192 16.384 32.768 btcl 76543210 rcwdt - adrst bts1 basic interval timer source clock select 000: f xin 8 001: f xin 16 010: f xin 32 011: f xin 64 100: f xin 128 101: f xin 256 110: f xin 512 111: f xin 1024 clear bit 0: normal operation (free-run) 1: clear 8-bit counter (bitr) to ?0?. this bit becomes 0 automatically initial value: 0-01 0111 b address: 0f2 h after one machine cycle, and starts counting. ckctlr initial value: undefined address: 0f2 h bitr both register are in same address, when write, to be a ckctlr, when read, to be a bitr. caution: 8-bit free-run binary counter wdton bts0 bts2 btcl btcl 76543210 watchdog timer enable bit 0: operate as 7-bit timer see the section ?watchdog timer?. address trap reset selection 0: enable address fail reset 1: disable address fail reset 1: enable watchdog timer operation 0: disable internal rc watchdog timer 1: enable internal rc watchdog timer rc watchdog selection bit .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 39 12. watchdog timer the watchdog timer rapidly detects the cpu malfunction such as endless looping caused by noise or the like, and re- sumes the cpu to the normal state. the watchdog timer signal for detecting malfunction can be selected either a re- set cpu or a interrupt request. when the watchdog timer is not being used for malfunc- tion detection, it can be used as a timer to generate an in- terrupt at fixed intervals. the watchdog timer has two types of clock source. the first type is an on-chip rc oscillator which does not re- quire any external components. this rc oscillator is sepa- rate from the external oscillator of the x in pin. it means that the watchdog timer will run, even if the clock on the x in pin of the device has been stopped, for example, by en- tering the stop mode. the other type is a prescaled sys- tem clock. the watchdog timer consists of 7-bit binary counter and the watchdog timer data regist er. when the value of 7-bit binary counter is equal to the lower 7 bits of wdtr, the interrupt request flag is generated. this can be used as watchdog timer interrupt or reset the cpu in accordance with the bit wdton. note: because the watchdog timer count er is enabled after clear- ing basic interval timer, after th e bit wdton set to "1", maximum error of timer is depend on prescale r ratio of basic interval timer. the 7-bit binary counter is cleared by setting wdtcl(bit7 of wdtr) and the wdtcl is cleared aut omatically after 1 machine cycle. the rc oscillated watchdog timer is activated by setting the bit rcwdt as shown below. ldm ckctlr,#3fh; enable the rc-osc wdt ldm wdtr,#0ffh ; set the wdt period ldm sscr, #5ah ;ready for stop mode stop ; enter the stop mode nop nop ; rc-osc wdt running : the rc-wdt oscillation period is vary with temperature, v dd and process variations from part to part (approxi- mately, 33~100us). the following equation shows the rcwdt oscillated watchdog timer time-out. t rcwdt =clk rcwdt 2 8 wdtr + (clk rcwdt 2 8) /2 where, clk rcwdt = 33~100us in addition, this watchdog timer can be used as a simple 7- bit timer by interrupt wdtif. the interval of watchdog timer interrupt is decided by basic interval timer. interval equation is as below. t wdt = (wdtr+1) interval of bit figure 12-1 block diagram of watchdog timer to reset cpu basic interval timer count enable watchdog 7-bit compare data comparator watchdog timer interrupt clear clear wdtif counter (7-bit) wdtcl ?0? ?1? wdton in ckctlr [0f2 h ] overflow watchdog timer register wdtr internal bus line 7 [0f4 h ] source .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 40 mar. 2005 ver 0.2 watchdog timer control figure 12-2 shows the watchdog timer control register. the watchdog timer is automatically disabled after reset. the cpu malfunction is detected during setting of the de- tection time, selecting of outp ut, and clearing of the binary counter. clearing the binary co unter is repeated within the detection time. if the malfunction occurs for any cause, the watchdog tim- er output will become active at the rising overflow from the binary counters unless the binary counter is cleared. at this time, when wdton=1, a reset is generated, which drives the reset pin to low to reset the internal hardware. when wdton=0, a watchdog timer interrupt (wdtif) is generated. the wdton bit is in register clkctlr. the watchdog timer temporarily stops counting in the stop mode, and when the stop mode is released, it au- tomatically restarts (continues counting). figure 12-2 wdtr: watchdog timer control register example: sets the watchdog timer detection time to 1 sec. at 4.194304mhz enable and disable watchdog watchdog timer is enabled by setting wdton (bit 4 in ckctlr) to ?1?. wdton is initialized to ?0? during re- set and it should be set to ?1? to operate after reset is re- leased. example: enables watc hdog timer for reset : ldm ckctlr,#xxx1_xxxxb; wdton 1 : : the watchdog timer is disabled by clearing bit 4 (wd- ton) of ckctlr. the watchdog timer is halted in stop mode and restarts automatica lly after stop mode is re- leased. watchdog timer interrupt the watchdog timer can be also used as a simple 7-bit tim- er by clearing bit4 of ckc tlr to ?0?. the interval of watchdog timer interrupt is decided by basic interval tim- er. interval equation is shown as below. t wdt = (wdtr+1) interval of bit the stack pointer (sp) should be initialized before using the watchdog timer output as an interrupt source. example: 7-bit timer interrupt set up. ldm ckctlr,#xxx0_xxxxb; wdton 0 ldm wdtr,#8fh ; wdtcl 1 76543210 wdtcl clear count flag 0: free-run count initial value: 0111 1111 b address: 0f4 h wdtr ww ww 1: when the wdtcl is set to ?1?, binary counter is cleared to ?0?. and the wdtcl becomes ?0? automatically after one machine cycle. counter count up again. 7-bit compare data wwww ldm ckctlr,#3fh ; select 1/1024 clock source , wdton 1, clear counter ldm wdtr,#08fh ldm wdtr,#08fh ; clear counter : : : : ldm wdtr,#08fh ; clear counter : : : : ldm wdtr,#08fh ; clear counter within wdt detection time within wdt detection time .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 41 : figure 12-3 watchdog timer timing if the watchdog timer output becomes active, a reset is gen- erated, which drives the reset pin low to reset the inter- nal hardware. the main clock oscillator al so turns on when a watchdog timer reset is generated in sub clock mode. 2 3 n source clock binary-counter wdtr wdtif interrupt wdtr ?1000_0011 b ? 1 0 match detect counter clear 1 2 30 bit overflow 3 wdt reset reset counter clear .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 42 mar. 2005 ver 0.2 13. timer/event counter thehms83f012/022 has four timer/counter registers. each module can generate an interrupt to indicate that an event has occurred (i.e. timer match). timer 0 and timer 1 are can be used either two 8-bit tim- er/counter or one 16-bit timer/counter with combine them. also timer 2 and timer 3 are same. timer 4 is 16- bit timer/counter. in the ?timer? function, the re gister is increased every in- ternal clock input. thus, one can think of it as counting in- ternal clock input. since a least clock consists of 2 and most clock consists of 2048 oscillator periods, the count rate is 1/2 to 1/2048 of the oscillator frequency. in the ?counter? function, the re gister is increased in re- sponse to a 0-to-1 (rising ed ge) transition at its correspond- ing external input pin, ec0 or ec1. in addition the ?capture? functi on, the register is increased in response external or inte rnal clock sources same with timer or counter function. when external clock edge input, the count register is captured into timer data register cor- respondingly. when external clock edge input, the count register is captured into capture data register cdrx. timer 0 and timer 1 is shared with "pwm" function and "compare output" function. it has six operating modes: "8- bit timer/counter", "16-bit timer/counter", "8-bit capture", "16-bit capture", "8-bit co mpare output", and "10-bit pwm" which are selected by bit in timer mode register tm0 and tm1 as shown in table 13-1, figure 13-1 . timer 2 and timer 3 is shared with "pwm" function and "compare output" function. it has six operating modes: "8- bit timer/counter", "16-bit timer/counter", "8-bit capture", "16-bit capture", "8-bit co mpare output", and "10-bit pwm" which are selected by bit in timer mode register tm2 and tm3 as shown in table 13-2, figure 13-2 . table 13-1 operation modes of timer 0, 1 16bit cap0 cap1 pwm1e t0ck [2:0] t1ck [1:0] pwm1o timer 0 timer 1 0 0 0 0 xxx xx 0 8-bit timer 8-bit timer 0 0 1 0 111 xx 0 8-bit event counter 8-bit capture 0 1 0 0 xxx xx 1 8-bit capture (internal clock) 8-bit compare output 0 x 0 1 xxx xx 1 8-bit timer/counter 10-bit pwm 1 0 0 0 xxx 11 0 16-bit timer 1 0 0 0 111 11 0 16-bit event counter 1 1 1 0 xxx 11 0 16-bit capture (internal clock) 1. x means the value of ?0? or ?1? corresponds to user operation. 16bit cap2 cap3 pwm3e t2ck [2:0] t3ck [1:0] pwm3o timer 2 timer 3 0 0 0 0 xxx xx 0 8-bit timer 8-bit timer 0 0 1 0 111 xx 0 8-bit event counter 8-bit capture 0 1 0 0 xxx xx 1 8-bit capture (internal clock) 8-bit compare output 0 x 0 1 xxx xx 1 8-bit timer/counter 10-bit pwm 1 0 0 0 xxx 11 0 16-bit timer 1 0 0 0 111 11 0 16-bit event counter 1 1 1 0 xxx 11 0 16-bit capture (internal clock) table 13-2 operating modes of timer 2, 3 .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 43 figure 13-1 tm0, tm1 registers btcl 76543210 16bit pol t1cn initial value: 00 h address: 0d2 h tm1 t1st t1ck0 t1ck1 pwm1e cap1 bit name bit position description pol tm1.7 0: pwm duty active low 1: pwm duty active high 16bit tm1.6 0: 8-bit mode 1: 16-bit mode pwm1e tm1.5 0: disable pwm 1: enable pwm cap1 tm1.4 0: timer/counter mode 1: capture mode selection flag t1ck1 t1ck0 tm1.3 tm1.2 00: 8-bit timer, clock source is f xin 01: 8-bit timer, clock source is f xin 4 10: 8-bit timer, clock source is f xin 16 11: 8-bit timer, clock source is using the timer 2 clock t1cn tm1.1 0: timer count pause 1: timer count start t1st tm1.0 0: when cleared, stop the counting. 1: when set, timer 0 count register is cleared and start again. btcl 543210 - - t0cn initial value: --00 0000 b address: 0d0 h tm0 t0st t0ck0 t0ck1 cap0 t0ck2 bit name bit position description cap0 tm0.5 0: timer/counter mode 1: capture mode selection flag t0ck2 t0ck1 t0ck0 tm0.4 tm0.3 tm0.2 000: 8-bit timer, clock source is f xin 2 001: 8-bit timer, clock source is f xin 4 010: 8-bit timer, clock source is f xin 8 011: 8-bit timer, clock source is f xin 32 100: 8-bit timer, clock source is f xin 128 101: 8-bit timer, clock source is f xin 512 110: 8-bit timer, clock source is f xin 2048 111: ec0 (external clock) t0cn tm0.1 0: timer count pause 1: timer count start t0st tm0.0 0: when cleared, stop the counting. 1: when set, timer 0 count register is cleared and start again. 76543210 initial value: 0ff h address: 0d1 h tdr0 read: count value read write: compare data write r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w 76543210 initial value: 0ff h address: 0d3 h tdr1 r/w r/w r/w r/w r/w r/w r/w r/w .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 44 mar. 2005 ver 0.2 figure 13-2 tm2, tm3 registers btcl 76543210 16bit pol t3cn initial value: 00 h address: 0d8 h tm3 t3st t3ck0 t3ck1 pwm3e cap3 bit name bit position description pol tm3.7 0: pwm duty active low 1: pwm duty active high 16bit tm3.6 0: 8-bit mode 1: 16-bit mode pwm3e tm3.5 0: disable pwm 1: enable pwm cap3 tm3.4 0: timer/counter mode 1: capture mode selection flag t3ck1 t3ck0 tm3.3 tm3.2 00: 8-bit timer, clock source is f xin 01: 8-bit timer, clock source is f xin 4 10: 8-bit timer, clock source is f xin 16 11: 8-bit timer, clock source is using the timer 2 clock t3cn tm3.1 0: timer count pause 1: timer count start t3st tm3.0 0: when cleared, stop the counting. 1: when set, timer 0 count register is cleared and start again. btcl 543210 - - t2cn initial value: --00 0000 b address: 0d6 h tm2 t2st t2ck0 t2ck1 cap2 t2ck2 bit name bit position description cap2 tm2.5 0: timer/counter mode 1: capture mode selection flag t2ck2 t2ck1 t2ck0 tm2.4 tm2.3 tm2.2 000: 8-bit timer, clock source is f xin 2 001: 8-bit timer, clock source is f xin 4 010: 8-bit timer, clock source is f xin 8 011: 8-bit timer, clock source is f xin 16 100: 8-bit timer, clock source is f xin 64 101: 8-bit timer, clock source is f xin 256 110: 8-bit timer, clock source is f xin 1024 111: ec1 (external clock) t2cn tm2.1 0: timer count pause 1: timer count start t2st tm2.0 0: when cleared, stop the counting. 1: when set, timer 0 count register is cleared and start again. 76543210 initial value: 0ff h address: 0d7 h tdr2 read: count value read write: compare data write r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w 76543210 initial value: 0ff h address: 0d9 h tdr3 r/w r/w r/w r/w r/w r/w r/w r/w .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 45 13.1 8-bit timer / counter mode the hms83f012/022 has four 8-bit timer/counters, tim- er 0, timer 1, timer 2, timer 3. the timer 0, timer 1 are shown in figure 13-3 and timer 2, timer 3 are shown in figure 13-4 . the ?timer? or ?counter? functi on is selected by control registers tm0, tm1, tm2, tm3 as shown in figure 13-1 . to use as an 8-bit timer/counter mode, bit cap0, cap1, cap2, or cap3 of tmx shou ld be cleared to ?0? and 16bit and pwm1e or pwm3e of tm1 or tm3 should be cleared to "0" (figur e 13-3 ). these timers have each 8-bit count register and data regist er. the count register is in- creased by every internal or ex ternal clock input. the inter- nal clock has a prescaler divide ratio option of 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 or external clock (select- ed by control bits txck0, txck1, txck2 of register tmx). figure 13-3 8-bit timer/counter 0, 1 ec0 pin 2 4 8 x in pin mux prescaler clear 0: stop 1: clear and start t0st t0ck[2:0] 111 000 001 010 t0cn mux t1if clear 0: stop 1: clear and start t1st t1ck[1:0] 11 00 01 timer 1 interrupt 1 2 8 tdr0 (8-bit) tdr1 (8-bit) t1 (8-bit) t0 (8-bit) comparator comparator timer 0 timer 1 btcl 76543210 - -t0cn initial value: --00 0000 b address: 0d0 h tm0 t0st t0ck0 t0ck1 cap0 t0ck2 -- xx x x x means don?t care 32 128 512 2048 011 100 101 110 t0if timer 0 interrupt t1cn 10 initial value: 00 h address: 0d2 h tm1 x means don?t care 0x btcl 76543210 16bit pol t1cn t1st t1ck0 t1ck1 pwm1e cap1 x0 x x x x 00 edge detector f/f r05 / t0o .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 46 mar. 2005 ver 0.2 figure 13-4 8-bit timer/counter 2, 3 ec1 pin 2 4 8 x in pin mux prescaler clear 0: stop 1: clear and start t2st t2ck[2:0] 111 000 001 010 t2cn mux t3if clear 0: stop 1: clear and start t3st t3ck[1:0] 11 00 01 timer 3 interrupt 1 4 16 tdr2 (8-bit) tdr3 (8-bit) t3 (8-bit) t2 (8-bit) comparator comparator timer 2 timer 3 btcl 76543210 - -t2cn initial value: --000000 b address: 0d6 h tm2 t2st t2ck0 t2ck1 cap2 t2ck2 -- xx x x x means don?t care 16 64 256 1024 011 100 101 110 t2if timer 2 interrupt t3cn 10 initial value: 00 h address: 0d8 h tm3 x means don?t care 0x btcl 76543210 16bit pol t3cn t3st t3ck0 t3ck1 pwm3e cap3 x0 x x x x 00 edge detector f/f r06 / t2o .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 47 example 1: timer0 = 2ms 8-bit timer mode at 4mhz timer1 = 0.5ms 8-bit timer mode at 4mhz timer2 = 1ms 8-bit timer mode at 4mhz timer3 = 1ms 8-bit timer mode at 4mhz ldm tdr0,#249 ldm tdr1,#249 ldm tdr2,#249 ldm tdr3,#249 ldm tm0,#0000_1111b ldm tm1,#0000_1011b ldm tm2,#0000_1111b ldm tm3,#0000_1011b set1 t0e set1 t1e set1 t2e set1 t3e ei example 2: timer0 = 8-bit event counter mode timer1 = 0.5ms 8-bit timer mode at 4mhz timer2 = 8-bit event counter mode timer3 = 1ms 8-bit timer mode at 4mhz ldm tdr0,#249 ldm tdr1,#249 ldm tdr2,#249 ldm tdr3,#249 ldm tm0,#0001_1111b ldm tm1,#0000_1011b ldm tm2,#0001_1111b ldm tm3,#0000_1011b set1 t0e set1 t1e set1 t2e set1 t3e ei these timers have each 8-bit c ount register and data regis- ter. the count register is incr eased by every internal or ex- ternal clock input. the internal clock has a prescaler divide ratio option of 2, 4, 8, 32, 128, 512, 2048 selected by con- trol bits t0ck[2:0] of register tm0 or 1, 2, 8 selected by control bits t1ck[1:0] of register tm1, or 2, 4, 8, 16, 64, 256, 1024 selected by control bits t2ck[2:0] of register tm2, or 1, 4, 16 selected by control bits t3ck[1:0] of reg- ister tm3. in the timer 0, ti mer register t0 increases from 00 h until it matches tdr0 and then reset to 00 h . the match output of timer 0 generates timer 0 interrupt (latched in t0if bit). in counter function, the coun ter is increased every 0-to-1 (rising edge) transition of ec0 pin. in order to use counter function, the bit ec0 of the port selection register (psr0.4) is set to "1". the ti mer 0 can be used as a counter by pin ec0 input, but timer 1 can not. likewise, in order to use timer2 as counter function, the bit ec1 of the port selection register (psr0.5) is set to "1". the timer 2 can be used as a counter by pin ec1 input, but timer 3 can not. 13.1.1 8-bit timer mode in the timer mode, the internal clock is used for counting up. thus, you can think of it as counting internal clock in- put. the contents of tdr n are compared with the contents of up-counter, t n . if match is found, a timer n interrupt (t n if) is generated and the up-counter is cleared to 0. counting up is resumed after the up-counter is cleared. as the value of tdr n is changeable by software, time in- terval is set as you want . figure 13-5 timer mode timing chart 0 n-2 2 0 n 3 n-1 n source clock up-counter tdr1 t1if interrupt start count 1 23 1 4 match detect counter clear ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 48 mar. 2005 ver 0.2 figure 13-6 timer count example 13.1.2 8-bit event counter mode in this mode, counting up is started by an external trigger. this trigger means rising edge of the ec0 or ec1 pin input. source clock is used as an inte rnal clock selected with tim- er mode register tm0 or tm2. the contents of timer data register tdr n (n = 0,1,2,3) are comp ared with the contents of the up-counter t n . if a match is found, an timer interrupt request flag t n if is generated, and the counter is cleared to ?0?. the counter is restart and count up continuously by every falling edge of the ec0 or ec1 pin input. the maxi- mum frequency applied to the ec0 or ec1 pin is f xin /2 [hz]. in order to use event counter function, the bit 4, 5 of the port selection register psr0(address 0f8 h ) is required to be set to ?1?. after reset, the value of timer data register tdr n is initial- ized to "0", the interval period of timer is calculated as below equation. figure 13-7 event counter mode timing chart ~ ~ timer 0 (t0if) interrupt tdr0 time occur interrupt occur interrupt occur interrupt interrupt period up-count ~ ~ ~ ~ 0 1 2 3 4 5 6 7a 7c count pulse = 8 s x (124+1) 7b match example: make 1ms interrupt using by timer0 at 4mhz ldm tm0,#0fh ; divide by 32 ldm tdr0,#124 ; 8us x (124+1)= 1ms set1 t0e ; enable timer 0 interrupt ei ; enable master interrupt period when tdr0 = 124 d = 7c h f xin = 4 mhz interrupt period = 4 10 6 hz 1 32 (124+1) = 1 ms tm0 = 0000 1111 b (8-bit timer mode, prescaler divide ratio = 32) 8 s (tdr0 = t0) 7c 0 period (sec) 1 f xin ---------- - 2 divide ratio (tdrn+1 ) = 0 1 2 1 0 n 2 ~ ~ ~ ~ ~ ~ n-1 n ~ ~ ~ ~ ~ ~ ecn pin input up-counter tdr1 t1if interrupt start count .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 49 figure 13-8 count operation of timer / event counter timer 1 (t1if) interrupt tdr1 time occur interrupt occur interrupt stop clear & start disable enable start & stop t1st t1cn control count u p- c o un t ~ ~ ~ ~ t1st = 0 t1st = 1 t1cn = 0 t1cn = 1 .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 50 mar. 2005 ver 0.2 13.2 16-bit timer / counter mode the timer register is being run with all 16 bits. a 16-bit timer/counter register t0, t1 are incremented from 0000 h until it matches tdr0, tdr1 and then resets to 0000 h . the match output generates timer 0 interrupt. the clock source of the timer 0 is selected either internal or external clock by bit t0ck[2:0]. in 16-bit mode, the bits t1ck[1:0] and 16bit of tm1 should be set to "1" respec- tively as shown in figure 13-9 . likewise, a 16-bit timer/counter register t2, t3 are incre- mented from 0000 h until it matches tdr2, tdr3 and then resets to 0000 h . the match output generates timer 2 inter- rupt. the clock source of the timer 2 is selected either internal or external clock by bit t2ck[2:0]. in 16-bit mode, the bits t3ck[1:0] and 16bit of tm3 should be set to "1" respec- tively as shown in figure 13-10 . even if the timer 0 (including timer 1) is used as a 16-bit timer, the timer 2 and timer 3 can still be used as either two 8-bit timer or one 16-bit timer by setting the tm3. re- versely, even if the timer 2 (i ncluding timer 3) is used as a 16-bit timer, the timer 0 and timer 1 can still be used as 8-bit timer independently. figure 13-9 16-bit time r/counter for timer 0, 1 clear 0: stop 1: clear and start t0st t0cn tdr1 + tdr0 comparator timer 0 + timer 1 timer 0 (16-bit) higher byte lower byte (16-bit) compare data t1 + t0 (16-bit) (not timer 1 interrupt) edge btcl 76543210 - -t0cn initial value: --00 0000 b address: 0d0 h tm0 t0st t0ck0 t0ck1 cap0 t0ck2 -- xx x x x means don?t care initial value: 00 h address: 0d2 h tm1 x means don?t care 0x btcl 76543210 16bit pol t1cn t1st t1ck0 t1ck1 pwm1e cap1 x1 x x 1 1 00 ec0 pin 2 4 8 x in pin mux prescaler t0ck[2:0] 111 000 001 010 32 128 512 2048 011 100 101 110 detector t0if timer 0 interrupt .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 51 figure 13-10 16-bit time r/counter for timer 2, 3 13.3 8-bit compare output (16-bit) thehms83f012/022 has timer compare output func- tion. to pulse out, the timer match can goes to port pin( t0o or t2o) as shown in figure 13-3 or figure 13-4 . thus, pulse out is generated by the timer match. these op- eration is implemented to pin, r05/an5//t0o/txd or r06/an6/t2o/ack. in this mode, the bit t0oe or t2oe bit of port selection register1 (psr1.0 or psr1.1) should be set to "1". this pin output the signal having a 50 : 50 duty square wave, and output frequency is same as below equation. 13.4 8-bit capture mode the timer 0 capture mode is set by bit cap0 of timer mode register tm0 (bit cap1 of timer mode register tm1 for timer 1) as shown in figure 13-11 . likewise, the tim- er 2 capture mode is set by bit cap2 of timer mode register tm2 (bit cap3 of timer mode register tm3 for timer 3) as shown in figure 13-12 . clear 0: stop 1: clear and start t2st t2cn tdr3 + tdr2 comparator timer 2 + timer 3 timer 2 (16-bit) higher byte lower byte (16-bit) compare data t3 + t2 (16-bit) (not timer 3 interrupt) edge btcl 76543210 - -t2cn initial value: --000000 b address: 0d6 h tm2 t2st t2ck0 t2ck1 cap2 t2ck2 -- xx x x x means don?t care initial value: 00 h address: 0d8 h tm3 x means don?t care 0x btcl 76543210 16bit pol t3cn t3st t3ck0 t3ck1 pwm3e cap3 x1 x x 1 1 00 ec1 pin 2 4 8 x in pin mux prescaler t2ck[2:0] 111 000 001 010 16 64 256 1024 011 100 101 110 detector t2if timer 2 interrupt f comp oscillation frequency 2 prescaler value tdr 1 ) + ( -------------------------------------------------------------------------------------------- - = .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 52 mar. 2005 ver 0.2 the timer/counter register is increased in response inter- nal or external input. this counting function is same with normal timer mode, and timer interrupt is generated when timer register t0 (t1, t2, t3) increases and matches tdr0 (tdr1, tdr2, tdr3). this timer interrupt in capture mode is very useful when the pulse width of captured sign al is more wider than the maximum period of timer. for example, in figure 13-14 , the pulse width of captured signal is wider than the timer data value (ff h ) over 2 times. when external interrupt is occurred, the captured value (13 h ) is more little than wanted value. it can be ob- tained correct value by counti ng the number of timer over- flow occurrence. timer/counter still does the above, but with the added fea- ture that a edge transition at external input intx pin causes the current value in the timer x register (t0,t1,t2,t3), to be captured into registers cdrx (cdr0, cdr1, cdr2, cdr3), respectively. after cap tured, timer x register is cleared and restarts by hardware. it has three transition modes: "falling edge", "rising edge", "both edge" which are selected by interrupt edge selection register ieds. re- fer to ?18.4 external interrupt? on page 84. in addition, the transition at int n pin generate an interrupt. note: the cdrn and tdrn are in same address.in the capture mode, reading operation is read the cdrn, not tdrn because path is opened to the cdrn. .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 53 figure 13-11 8-bit capture mode for timer 0, 1 int0if 0: stop 1: clear and start t0st int0 interrupt t0cn cdr0 (8-bit) t0 (8-bit) ?01? ?10? ?11? capture ieds[1:0] ec0 pin 2 4 8 x in pin mux prescaler t0ck[2:0] 111 000 001 010 mux t1ck[1:0] 11 00 01 1 2 8 32 128 512 2048 011 100 101 110 10 int0 pin int1if 0: stop 1: clear and start t1st int1 interrupt t1cn cdr1 (8-bit) t1 (8-bit) ?01? ?10? ?11? capture ieds[3:2] int1 pin btcl 76543210 - -t0cn initial value: --00 0000 b address: 0d0 h tm0 t0st t0ck0 t0ck1 cap0 t0ck2 -- xx x x x means don?t care initial value: 00 h address: 0d2 h tm1 x means don?t care 1x btcl 76543210 16bit pol t1cn t1st t1ck0 t1ck1 pwm1e cap1 x0 x x x x 01 edge detector clear clear .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 54 mar. 2005 ver 0.2 figure 13-12 8-bit capture mode for timer 2, 3 int2if 0: stop 1: clear and start t2st int2 interrupt t2cn cdr2 (8-bit) t2 (8-bit) ?01? ?10? ?11? capture ieds[5:4] ec1 pin 2 4 8 x in pin mux prescaler t2ck[2:0] 111 000 001 010 mux t3ck[1:0] 11 00 01 1 4 16 16 64 256 1024 011 100 101 110 10 int2 pin int3if 0: stop 1: clear and start t3st int3 interrupt t3cn cdr3 (8-bit) t3 (8-bit) ?01? ?10? ?11? capture ieds[7:6] int3 pin btcl 76543210 - -t2cn initial value: --00 0000 b address: 0d6 h tm2 t2st t2ck0 t2ck1 cap2 t2ck2 -- xx x x x means don?t care initial value: 00 h address: 0d8 h tm3 x means don?t care 1x btcl 76543210 16bit pol t3cn t3st t3ck0 t3ck1 pwm3e cap3 x0 x x x x 01 edge detector clear clear .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 55 figure 13-13 input capture operation of timer 0 capture mode figure 13-14 excess timer overflow in capture mode ~ ~ ext. int0 pin interrupt request t0 time u p -cou n t ~ ~ ~ ~ 0 1 2 3 4 5 6 7 8 9 n n-1 capture ( timer stop ) clear & start interrupt interval period delay ( int0if ) ext. int0 pin interrupt request ( int0if ) this value is loaded to cdr0 20ns 5ns interrupt interval period=01 h +ff h +01 h +ff h +01 h +13 h =214 h ff h ff h ext. int0 pin interrupt request ( int0if ) 00 h 00 h interrupt request ( t0if ) t0 13 h .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 56 mar. 2005 ver 0.2 13.5 16-bit capture mode 16-bit capture mode is the same as 8-bit capture, except that the timer register is being run will 16 bits. the clock source of the timer 0 is selected either internal or external clock by bit t0ck[2:0]. in 16-bit mode, the bits t1ck1, t1ck0, cap1 and 16bit of tm1 should be set to "1" re- spectively as shown in figure 13-15 . the clock source of the timer 2 is selected either internal or external clock by bit t2ck[2:0]. in 16-bit mode, the bits t3ck1,t3ck0, cap3 and 16bit of tm3 should be set to "1" respectively as shown in figure 13-16 . figure 13-15 16-bit capture mode of timer 0, 1 0: stop 1: clear and start t0st t0cn capture cdr1 + cdr0 higher byte lower byte (16-bit) capture data tdr1 + tdr0 (16-bit) int0if int0 interrupt ?01? ?10? ?11? ieds[1:0] ec0 pin 2 4 8 x in pin mux prescaler t0ck[2:0] 111 000 001 010 32 128 512 2048 011 100 101 110 int0 pin btcl 76543210 - -t0cn initial value: --00 0000 b address: 0d0 h tm0 t0st t0ck0 t0ck1 cap0 t0ck2 -- xx x x x means don?t care initial value: 00 h address: 0d2 h tm1 x means don?t care 1x btcl 76543210 16bit pol t1cn t1st t1ck0 t1ck1 pwm1e cap1 x1 x x 1 1 01 edge detector clear .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 57 figure 13-16 16-bit capture mode of timer 2, 3 example 1: timer0 = 16-bit timer mode, 0.5s at 4mhz ldm tm0,#0000_1111b;8us ldm tm1,#0100_1100b;16bit mode ldm tdr0,#<62499 ;8us x 62500 ldm tdr1,#>62499 ;=0.5s set1 t0e ei : : example 2: timer0 = 16-bit event counter mode ldm psr0,#0001_0000b;ec0 set ldm tm0,#0001_1111b;countermode ldm tm1,#0100_1100b;16bit mode ldm tdr0,#<0ffh ; ldm tdr1,#>0ffh ; set1 t0e ei : : example 3: timer0 = 16-bit capture mode ldm psr0,#0000_0001b;int0 set ldm tm0,#0010_1111b;capturemode ldm tm1,#0100_1100b;16bit mode ldm tdr0,#<0ffh ; ldm tdr1,#>0ffh ; ldm ieds,#01h;falling edge set1 t0e ei : : 0: stop 1: clear and start t2st t2cn capture cdr3 + cdr2 higher byte lower byte (16-bit) capture data tdr3 + tdr2 (16-bit) int2if int2 interrupt ?01? ?10? ?11? ieds[5:4] ec1 pin 2 4 8 x in pin mux prescaler t2ck[2:0] 111 000 001 010 16 64 256 1024 011 100 101 110 int2 pin btcl 76543210 - -t2cn initial value: --00 0000 b address: 0d6 h tm2 t2st t2ck0 t2ck1 cap2 t2ck2 -- xx x x x means don?t care initial value: 00 h address: 0d8 h tm3 x means don?t care 1x btcl 76543210 16bit pol t3cn t3st t3ck0 t3ck1 pwm3e cap3 x1 x x 1 1 0 1 edge detector clear .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 58 mar. 2005 ver 0.2 13.6 pwm mode thehms83f012/022 has high speed pwm (pulse width modulation) functions which shared with timer1 or timer3. in pwm mode, r10 / pwm1o or r11 / pwm3o pin out- put up to a 10-bit resolution pwm output. these pins should be configured as a pwm output by setting "1" bit pwm1oe and pwm3oe in psr0 register. the period of the pwm1 output is determined by the t1ppr (t1 pwm period register) and t1pwhr[3:2] (bit3,2 of t1 pwm high register) and the duty of the pwm output is determined by the t1pdr (t1 pwm duty register) and t3pwhr[1:0] (bit1,0 of t1 pwm high register). the period of the pwm3 output is determined by the t3ppr (t3 pwm period register) and t3pwhr[3:2] (bit3,2 of t3 pwm high register) and the duty of the pwm output is determined by the t3pdr (t3 pwm duty register) and t3pwhr[1:0] (bit1,0 of t3 pwm high register). the user writes the lower 8-bit period value to the t1(3)ppr( and the higher 2-bit period value to the t1(3)pwhr[3:2]. and writes duty value to the t1(3)pdr and the t1(3)pwhr[1:0] same way. the t1(3)pdr is configured as a double buffering for glitchless pwm output. in figure 13-18 , the duty data is transferred from the master to the slave when the period data matched to the counted value. (i.e. at the beginning of next duty cycle) pwm1(3) period = [pwm1(3)hr[3:2]t(2)3ppr] x source clock pwm1(3) duty = [pwm3hr[1:0]t3pdr] x source clock the relation of frequency and resolution is in inverse pro- portion. table 13-3 shows the relation of pwm frequency vs. resolution. if it needed more higher frequency of pwm, it should be reduced resolution. the bit pol of tm1 or tm3 decides the polarity of duty cycle. if the duty value is set same to the period value, the pwm output is determined by the bit pol (1: high, 0: low). and if the duty value is set to "00 h ", the pwm output is deter- mined by the bit pol (1: low, 0: high). it can be changed duty valu e when the pwm output. how- ever the changed duty value is output after the current pe- riod is over. and it can be maintained the duty value at present output when changed only period value shown as figure 13-20 . as it were, the absolute duty time is not changed in varying frequency. but the changed period val- ue must greater than the duty value. note: if changing the timer1 to pwm function, it should be stop the timer clock firstly, and then set period and duty register value. if user writes register values while timer is in operation, these reg- ister could be set with certain values. ex) sample program @4mhz 2us ldm tm1,#1010_1000b ; set clock & pwm3e ldm t1ppr,#199 ; period :400us=2usx(199+1) ldm t1pdr,#99 ; duty:200us=2usx(99+1) ldm pwm1hr,00h ldm tm1,#1010_1011b ; start timer1 resolution frequency t1ck[1:0] = 00(250ns) t1ck[1:0] = 01(500ns) t1ck[1:0] = 10(2us) 10-bit 3.9khz 0.98khz 0.49khz 9-bit 7.8khz 1.95khz 0.97khz 8-bit 15.6khz 3.90khz 1.95khz 7-bit 31.2khz 7.81khz 3.90khz table 13-3 pwm frequency vs. resolution at 4mhz .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 59 figure 13-17 pwm1 mode t1st 0 : stop 1 : clear and start clear sq r pol pwm1oe [psr0.6] period high duty high bit manipulation not available initial value: 00 h address: 0d2 h tm1 btcl 76543210 16bit pol t3cn t3st t3ck0 t3ck1 pwm1e cap3 x0 x x x x 10 r/w r/w r/w r/w r/w r/w r/w r/w initial value: ---- 0000 b address: 0d5 h t1pwhr x:the value "0" or "1" corresponding your operation. btcl 76543210 - - t3pwhr1 t3pwhr0 t3pwhr2 t3pwhr3 - - -- xx x x - - - - - -wwww initial value: 0ff h address: 0d3 h t1ppr btcl 76543210 wwwwwwww initial value: 00 h address: 0d4 h t1pdr btcl 76543210 r/w r/w r/w r/w r/w r/w r/w r/w x:the value "0" or "1" corresponding your operation. t1pdr(8-bit) t1pdr(8-bit) t1pwhr[1:0] slave master t1ppr(8-bit) t1pwhr[1:0] comparator t1cn 1 2 8 x in pin mux prescaler 00 01 10 t1ck[1:0] t0 clock source [t0ck] t1(8-bit) 2-bit comparator r10 / pwm1o pin 11 .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 60 mar. 2005 ver 0.2 figure 13-18 pwm3 mode t3st 0 : stop 1 : clear and start clear sq r pol pwm3o [psr0.7] period high duty high bit manipulation not available initial value: 00 h address: 0d8 h tm3 btcl 76543210 16bit pol t3cn t3st t3ck0 t3ck1 pwm3e cap3 x0 x x x x 10 r/w r/w r/w r/w r/w r/w r/w r/w initial value: ---- 0000 b address: 0db h t3pwhr x:the value "0" or "1" corresponding your operation. btcl 76543210 - - t3pwhr1 t3pwhr0 t3pwhr2 t3pwhr3 - - -- xx x x - - - - - -wwww initial value: 0ff h address: 0d9 h t3ppr btcl 76543210 wwwwwwww initial value: 00 h address: 0da h t3pdr btcl 76543210 r/w r/w r/w r/w r/w r/w r/w r/w x:the value "0" or "1" corresponding your operation. t3pdr(8-bit) t3pdr(8-bit) t3pwhr[1:0] slave master t3ppr(8-bit) t3pwhr[1:0] comparator t3cn 1 4 16 x in pin mux prescaler 00 01 10 t3ck[1:0] t2 clock source [t2ck] t3(8-bit) 2-bit comparator r11 / pwm3o pin 11 .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 61 figure 13-19 example of pwm1 at 4mhz figure 13-20 example of changing the pwm1 period in absolute duty cycle (@4mhz) source t1 pwm1o ~ ~ ~ ~ ~ ~ 01 02 03 04 7e 7f 80 01 02 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ [pol=1] pwm1o [pol=0] duty cycle [ (1+7fh) x 250ns = 32us ] period cycle [ (3ffh+1) x 250ns = 256us, 3.9khz ] t1pwhr = 0ch t1ppr = ffh t1pdr = 7fh t1ck[1:0] = 00 ( xin ) t1pwhr3 t1pwhr2 t1pwhr1 t1pwhr0 t1ppr (8-bit) t1pdr (8-bit) period duty 1 1 ffh 00 7fh 00 clock pwm1e ~ ~ t1st ~ ~ t1cn ~ ~ 00 3ff source t1 pwm1o pol=1 duty cycle period cycle [ (1+0dh) x 2us = 28us, 35.5khz ] pwm1hr = 00h t1ppr = 0dh t1pdr = 04h t1ck[1:0] = 10 ( 1us ) 01 02 03 04 05 07 08 0a 0b 0c 0d 00 01 02 03 04 05 06 07 08 09 00 01 02 03 06 09 04 [ (04h+1) x 2us = 10us ] duty cycle [ (04h+1) x 2us = 10us ] period cycle [ (1+09h) x 2us = 20us, 50khz ] duty cycle [ (04h+1) x 2us = 10us ] write t1ppr to 09h clock 00 .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 62 mar. 2005 ver 0.2 14. analog to digital converter the analog-to-digital converter (a/d) allows conversion of an analog input signal to a corresponding 10-bit digital value. the a/d module has ten (eight for hms83f012) analog inputs, which are multiplexed into one sample and hold. the output of the sample and hold is the input into the converter, which generates the result via successive ap- proximation. the analog reference voltage is selected to v dd or avref by setting of the bit avrefs in psr1 register. if external analog reference avref is sel ected, the analog input chan- nel 0 (an0) should not be selected to use. because this pin is used to an analog re ference of a/d converter. the a/d module has three regi sters which are the control register adcm and a/d result register adcrh and ad- crl. the adcrh[7:6] is used as adc clock source se- lection bits too. the register adcm, shown in figure 14- 4 , controls the operation of the a/d converter module. the port pins can be configured as analog inputs or digital i/o. it is selected for the corres ponding channel to be converted by setting ads[3:0]. the a/d port is set to analog input port by aden and ads[3:0] regardless of port i/o direc- tion register. the port unselected by ads[3:0] operates as normal port. figure 14-1 a/d converter operation flow how to use a/d converter the processing of conversion is start when the start bit adst is set to ?1?. after one cycle, it is cleared by hard- ware. the register adcrh and adcrl contains the re- sults of the a/d conversion. when the co nversion is completed, the result is loaded into the adcrh and ad- crl, the a/d conversion status bit adsf is set to ?1?, and the a/d interrupt flag adcif is set. see figure 14-1 for operation flow. the block diagram of the a/d module is shown in figure 14-3 . the a/d status bit adsf is set automatically when a/d conversion is completed, cleared when a/d conver- sion is in process. the conversion time takes 13 times of conversion source clock. the conversion source clock should selected for the conversion time being more than 25 s. a/d converter cautions (1) input range of an0 ~ an7, an14 and an15 the input voltage of a/d input pins should be within the specification range. in particular, if a voltage above v dd (or avref) or below v ss is input (even if within the abso- lute maximum rating range), the conversion value for that channel can not be indeterminate. the conversion values of the other channels may also be affected. (2) noise countermeasures in order to maintain 10-bit resolution, attention must be paid to noise on pins v dd (or avref) and analog input pins (an0 ~ an7, an14, an15). sin ce the effect increases in proportion to the output impedance of the analog input source, it is recommended in so me cases that a capacitor be connected externally as shown in figure 14-2 in order to reduce noise. the capacitance is user-selectable and appro- priately determin ed according to th e target system. figure 14-2 analog input pin connecting capacitor adsf = 1 yes no enable a/d converter a/d input channel select conversion source clock select a/d start (adst = 1) nop read adcr an0~an7 analog input 0~1000pf user selectable an14, an15 .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 63 (3) i/o operation the analog input pins an0 ~ an7,an14 and an15 also have function as input/output port pins. when a/d conver- sion is performed with any pin, be sure not to execute a port input instruction with the selected pin while conver- sion is in progress, as this may reduce the conversion res- olution. also, if digital pulses are ap plied to a pin adjacent to the pin in the process of a/d conversion, the expected a/d conversion value may not be obtainable due to coupling noise. therefore, av oid applying pulses to pins adjacent to the pin undergoing a/d conversion. (4) av dd pin input impedance a series resistor string of approximately 5k ? is connected between the av ref pin and the v ss pin. therefore, if the output impedance of the analog power source is high, this will result in parallel connection to the series resistor string between the av ref pin and the v ss pin, and there will be a large analog supply voltage error figure 14-3 a/d block diagram an0 / av ref sample & hold an1 an7 an14 successive approximation adcif adc result register adc interrupt mux resistor ladder circuit v dd ads[3:0] (adcm[5:2]) circuit aden adc result register adc8 01 2 3 8 9 0 1 adcrl (8-bit) 10-bit adcr adcrh 00 adcrl (8-bit) adcrh adcr (10-bit) 8 9 10-bit adcr 10-bit mode 8-bit mode 0 1 01 an15 avrefs (psr1.3) .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 64 mar. 2005 ver 0.2 figure 14-4 a/d converter control & result register btcl 76543210 aden adst a/d status bit analog input channel select initial value: 0000 0001 b address: 0ef h adcm adsf a/d converter clock source divide ratio selection bit 0: clock source f ps 1: clock source f ps 2 r/w r/w r/w r/w r/w r 0000: channel 0 (an0) 0001: channel 1 (an1) 0010: channel 2 (an2) 0011: channel 3 (an3) 0110: channel 6 (an6) 0111: channel 7 (an7) 1000 ~ 1101: not available 0: a/d conversion is in progress 1: a/d conversion is completed a/d start bit setting this bit starts an a/d conversion. after one cycle, bit is cleared to ?0? by hardware. ads1 ads0 ads3 ads2 adck 1110: channel 14 (an14) a/d converter enable bit 0: a/d converter module turn off and current is not flow. 1: enable a/d converter initial value: undefined address: 0f1 h adcrl a/d conversion low data r/w r/w btcl 76543210 pssel1 adcrh - - adc8 - pssel0 initial value: 010- ---- b address: 0f0 h a/d conversion high data a/d conversion clock (f ps ) source selection 00: f xin 4 01: f xin 8 10: f xin 16 11: f xin 32 btcl 76543210 - - -rr ww rrrrrr rr adck pssel1 pssel0 ps clock selection 0 0 0 ps = f xin 4 0 0 1 ps = f xin 8 0 0 0 ps = f xin 16 0 0 1 ps = f xin 32 1 1 0 ps = f xin 8 1 1 1 ps = f xin 16 1 1 0 ps = f xin 32 1 1 1 ps = f xin 64 ps : conversion clock adc 8-bit mode select bit 0: 10-bit mode 1: 8-bit mode w 0100: channel 4 (an4) 0101: channel 5 (an5) 1111: channel 15 (an15) .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 65 15. serial input/output (sio) the serial input/output is used to transmit/receive 8-bit data serially. the serial input/output (sio) module is a se- rial interface useful for comm unicating with other periph- eral of microcontroller devices. these peripheral devices may be serial eeproms, shift registers, display drivers, a/d converters, etc. this sio is 8-bit clock synchronous type and consists of serial i/ o data register, serial i/o mode register, clock selection circuit, octal counter and control circuit as illustrated in figure 15-1 . the so pin is designed to input and output. so the se rial i/o(sio) can be operated with minimum two pin. pin r00/sck, r01/si, and r02/ so pins are controlled by the serial mode register. the contents of the serial i/o data register can be written into or read out by software. the data in the serial data regis- ter can be shifted synchronously with the transfer clock signal. figure 15-1 sio block diagram 4 16 x in pin prescaler mux sck[1:0] 00 01 10 11 sck pin sio shift input shift register sior clock clock octal serial communication interrupt sioif internal bus siosf counter sck[1:0] ?11? overflow not ?11? complete timer0 overflow si pin iosw so pin sout iosw control circuit ?0? ?1? pol 1 0 start siost clear sm0 (3-bit) .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 66 mar. 2005 ver 0.2 serial i/o mode register (siom) controls serial i/o func- tion. according to sck1 and sck0, the internal clock or external clock can be selected. serial i/o data register (sior) is an 8-bit shift register. first lsb is send or is received. figure 15-2 sio control register 15.1 transmission/receiving timing the serial transmission is started by setting siost(bit1 of siom) to ?1?. after one cycl e of sck, siost is cleared automatically to ?0?. at the default state of pol bit clear, the serial output data from 8-bit shift register is output at falling edge of sclk, and input data is latched at rising edge of sclk pin (refer to figure 15-3 ). when transmis- sion clock is counted 8 times, serial i/o counter is cleared as ?0?. transmission clock is halted in ?h? state and serial i/o interrupt (sioif) occurred. btcl 76543210 iosw pol siost serial transmission status bit serial transmission clock selection initial value: 0000 0001 b address: 0e2 h siom siosf serial input pin selection bit 0: si pin selection 1: so pin selection r/w r/w r/w r/w r/w r 00: f xin 4 01: f xin 16 10: tmr0ov(timer0 overflow) 11: external clock 0: serial transmission is in progress 1: serial transmis sion is completed serial transmission start bit setting this bit starts an serial transmission. after one cycle, bit is cleared to ?0? by hardware. sck1 sck0 sm1 sm0 r/w serial transmission operation mode 00: normal port(r42,r43,r44) 01: sending mode(sck,r43,so) 10: receiving mode(sck,si,r44) 11: sending & receiving mode(sck,si,so) initial value: undefined address: 0e3 h sior btcl 76543210 r/w r/w r/w r/w r/w r/w r/w r/w sending data at sending mode receiving data at receiving mode serial clock polarity selection bit 0: data transmission at falling edge received data latch at rising edge 1: data transmission at rising edge received data latch at falling edge r/w .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 67 figure 15-3 serial i/o timing diagram at pol=0 figure 15-4 serial i/o timing diagram at pol=1 d1 d2 d3 d4 d6 d7 d0 d5 d1 d2 d3 d4 d6 d7 d0 d5 siost sck [r42] (pol=0) so [p44] si [r43] sioif (sio int. req) (iosw=0) d1 d2 d3 d4 d6 d7 d0 d5 ioswin [p44] (iosw=1) siosf (sio status) d1 d2 d3 d4 d6 d7 d0 d5 d1 d2 d3 d4 d6 d7 d0 d5 siost sck [r42] (pol=1) so [r44] si [r43] sioif (sio int. req) (iosw=0) d1 d2 d3 d4 d6 d7 d0 d5 ioswin [r44] (iosw=1) siosf (sio status) .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 68 mar. 2005 ver 0.2 15.2 the usage of serial i/o 1. select transmission/receiving mode. 2. in case of sending mode, write data to be send to sior. 3. set siost to ?1? to st art serial transmission. 4. the sio interrupt is generated at the completion of sio and sioif is set to ?1?. in sio interrupt service routine, correct transmission should be tested. 5. in case of receiving mode, the received data is acquired by reading the sior. note: when external clock is us ed, the frequency should be less than 1mhz and recommended duty is 50%. if both transmission mode is selected and transmission is performed simultaneously, error may be occur. 15.3 the method to test correct transmission figure 15-5 serial io method to test transmission ldm sior,#0aah ;set tx data ldm siom,#0011_1100b ;set sio mode nop ldm siom,#0011_1110b ;sio start serial i/o interrupt service routine sioe = 0 write siom normal operation overrun error abnormal siosf 0 1 - sioe: interrupt enable register high ienh(bit1) - sioif: interrupt request flag register high irqh(bit1) sioif 0 1 .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 69 16. universal asynchro nous receiver/transmitter (uart) 16.1 uart serial interface functions the universal asynchronous receiver / transmitter (uart) enables full-duplex operation wherein one byte of data after the start bit is tr ansmitted and received. the on- chip baud rate generator dedicated to uart enables com- munications using a wide range of selectable baud rates. in addition, a baud rate can also be defined by dividing clocks input to the aclk pin. the uart driver consists of rxr, txr, asimr, asisr and brgcr register. universal asynchronous serial i/o mode (uart) can be selected by asimr register. figure 16-1 shows a block diagram of the uart driver. figure 16-1 uart block diagram (asisr) transmit shift register internal data bus txd pin rxd pin txe rxe aclk pin f xin 2 ~ f xin 128 (txr) transmit controller (parity addition) receive buffer register (rxr) receive shift register (rx) receive controller (parity check) baud rate generator 210 pe fe ove int_tx (uart tramsmit interrupt) int_rx (uart receive interrupt) .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 70 mar. 2005 ver 0.2 figure 16-2 baud rate generator block diagram 16.2 serial interface configuration the uart interface consists of the following hardware. transmit shift register (txr) this is the register for setting transmit data. data written to txr is transmitted as serial data. when the data length is set as 7 bit, bit 0 to 6 of the data written to txr are trans- ferred as transmit data. writing data to txr starts the transmit operation. txr can be written by an 8 bit memory manipulation in- struction. it cannot be read. the reset input sets txr to 0ff h . receive buffer register (rxr) this register is used to hold receive data. when one byte of data is received, one byte of ne w receive data is transferred from the receive shift register (rxsr). when the data length is set as 7 bits, receive data is sent to bits 0 to 6 of rxr. in this case, the msb of rxr always becomes 0. rxr can be read by an 8 bit memory manipulation instruc- tion. it cannot be written. the reset input sets rxr to 00 h . receive shift register this register converts serial data input via the rxd pin to paralleled data. when one byte of data is received at this register cannot be manipulat ed directly by a program. asynchronous serial interface mode register (asimr) this is an 8 bit register that controls uart serial transfer operation. asimr is set by a 1 bit or 8 bit memory manip- ulation intruction. the reset input sets asimr to 0000_-00- b . figure 16-3 shows the format of asimr the rxd / r04 and txd / r05 pin function selection is shown in table 16-2. note: do not switch the operation mode until the current serial transmit/receive operation has stopped. mux receive rxe tx_clock rx_clock txe send 5-bit counter decoder 5-bit counter match match (brgcr) - tps2 tps1 tps0 mdl3 mdl2 mdl1 mdl0 aclk pin f xin 2 ~ f xin 128 internal data bus 2 (divider) 2 (divider) item configuration register transmit shift register (txr) receive buffer register (rxr) receive shift register control register serial interface mode register (asimr) serial interface status register (asisr) baud rate generator control register (brgcr) table 16-1 serial interface configuration .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 71 figure 16-3 asynchronous serial inte rface mode register (asimr) format btcl 76543210 rxe txe isrm uart stop bit length for specification for transmit data bit initial value: 0000 -00- b address: 0e6 h asimr - r/w r/w - r/w r/w - 0: 1 bit 1: 2 bit uart receive interrupt request is issued when an error occurs bit - sl ps1 ps0 r/w uart parity bit specification bit 00: no parity 01: zero parity always added during transmission. 10: odd parity 11: even parity uart tx/rx enable bit r/w 0: receive completion interrupt control when error occurs 1: receive completion interrupt request is not issued when an error occur no parity detection during reception (parity errors do not occur) 00: not used uart 01: uart receive only mode 10: uart transmit only mode 11: uart receive & transmit mode txe (asimr.7) rxe(asimr.6) ec0(psr0. 4) operation mode rxd/r04 txd/r05 00 x 1 operation stop r04 r05 0 1 0 uart mode (receive only) rxd r05 1 0 x uart mode (transmit only) r04 txd 1 1 0 uart mode (transmit and receive) rxd txd table 16-2 uart mode and rxd/txd pin function 1. x:the value "0" or "1" corresponding your operation .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 72 mar. 2005 ver 0.2 asynchronous serial interface status register (asisr) when a receive error occurs during uart mode, this reg- ister indicates the type of erro r. asisr can be read by an 8 bit memory manipulation instruction. the reset input sets asisr to ----_-000b. figure 16-4 shows the format of asisr. figure 16-4 asynchronous serial interface status register (asisr) format btcl 76543210 - - fe uart frame error flag initial value: ---- -000 b address: 0e7 h asisr ove rrr 0: no frame error 1: framing error note1 (stop bit not detected) uart parity error flag - pe - - uart overrun error flag 0: no overrun error 1: overrun error note2 0: no parity error 1: parity error (transmit data parity not matched) note 1. even if a stop bit length is set to 2 bits by setting bit2(sl) in asimr, stop bit detection during a recive operation only applies to a stop bit length of 1bit. 2. be sure to read the contents of the receive buffer register(rxr) when an overrun error has occurred. until the contents of rxr are re ad, futher overrun errors will occur when receiving data. (next receive operation was completed before data was read from receive buffer register (rxr)) .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 73 baud rate generator control register (brgcr) this register sets the serial clock for serial interface. brgcr is set by an 8 bit memory manipulation instruc- tion. the reset input sets brgcr to -001_0000b. figure 16-5 shows the format of brgcr. figure 16-5 baud rate generator control register (brgcr) format btcl 76543210 tps2 - mdl1 initial value: -001 0000 b address: 0e8 h brgcr mdl0 r/w r/w r/w r/w r/w r/w mdl3 mdl2 tps1 tps0 r/w uart source clock selection for 5 bit count 000: aclk 001: f xin 2 010: f xin 4 011: f xin 8 100: f xin 16 101: f xin 32 110: f xin 64 111: f xin 128 uart input clock selection 0000: f sck 16 0001: f sck 17 0010: f sck 18 0011: f sck 19 0100: f sck 20 0101: f sck 21 0110: f sck 22 0111: f sck 23 1000: f sck 24 1001: f sck 25 1010: f sck 26 1011: f sck 27 1100: f sck 28 1101: f sck 29 1110: f sck 30 1111: setting prohibited 1. f sck : source clock for 5 bit counter remarks writing to brgcr during a communication operation may cause abnormal output from the baud rate generator and disable further communication operations. therefore, do not write to brgcr during a communication operation. caution .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 74 mar. 2005 ver 0.2 16.3 communication operation the transmit operation is enab led when bit 7 (txe) of the asynchronous serial interface mode register (asimr) is set to 1. the transmit operat ion is started when transmit data is written to the transmit shift register (txr). the tim- ing of the transmit completion interrupt request is shown in figure 16-6 . the receive operation is enab led when bit 6 (rxe) of the asynchronous serial interface mode register (asimr) is set to 1, and input via the rxd pin is sampled. the serial clock specified by asimr is used to sample the rxd pin. once reception of one data frame is completed, a receive completion interrupt request (int_rx) occurs. even if an error has occurred, the receive data in which the error oc- curred is still transferred to rxr. when asimr bit 1 (is- rm) is cleared to 0 upon o ccurrence of an error, and int_rx occurs. when isrm bit is set to 1, int_rx does not occur in case of error occu rrence. figure 16-6 shows the timing of the asynchronous serial interface receive completion interrupt request. figure 16-6 uart data format an d interrupt timing diagram d0 d1 txd tx d2 rxd d4 d3 d6 d5 d7 parity interrupt stop 1 data frame character bits 1 data frame consists of following bits. - start bit : 1 bit - character bits : 8 bits - parity bit : even parity, odd parity, zero parity, no parity - stop bit(s) : 1 bit or 2 bits rx interrupt start 1. stop bit length : 1 bit d0 d1 txd tx d2 rxd d4 d3 d6 d5 d7 parity interrupt stop 1 data frame character bits rx interrupt start 2. stop bit length : 2 bit d0 d1 txd tx d2 rxd d4 d3 d6 d5 d7 interrupt 1 data frame character bits rx interrupt start 3. stop bit length : 1 bit, no parity stop .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 75 16.4 relationship between main clock and baud rate the transmit/receive clock that is used to generate the baud rate is obtained by dividing the main system clock. trans- mit/receive clock gene ration for baud rate is made by us- ing main system clock which is divided. the baud rate generated from the main system clock is determined ac- cording to the following formula. figure 16-7 relationship between main clock and baud rate baud rate (bps) f xin =11.05 92m f xin =10.0m f xin =8.0m f xin =4.0m f xin =2.0m brgcr err(%) brgcr err(%) brgcr err(%) brgcr err (%) brgcr err(%) 600 - - - - - - 7ah 0.16 6ah 0.16 1200 - - - - 7ah 0.16 6ah 0.16 5ah 0.16 2400 72h 0.00 70h 1.73 6ah 0.16 5ah 0.16 4ah 0.16 4800 62h 0.00 60h 1.73 5ah 0.16 4ah 0.16 3ah 0.16 9600 52h 0.00 50h 1.73 4ah 0.16 3ah 0.16 2ah 0.16 19200 42h 0.00 40h 1.73 3ah 0.16 2ah 0.16 1ah 0.16 31250 36h 0.53 34h 0.00 30h 0.00 20h 0.00 10h 0.00 38400 32h 0.00 30h 1.73 2ah 0.16 1ah 0.16 - - 57600 28h 0.00 26h 1.35 21h 2.11 11h 2.12 - - 76800 22h 0.00 20h 1.73 1ah 0.16 - - - - 115200 18h 0.00 16h 1.36 11h 2.12 - - - - 2. f sck : source clock for 5 bit counter 3. n : value set via tps0 to tps2 ( 0 n 7 ) 4. k : source clock for 5 bit counter ( 0 k 14 ) remarks 1. f xin : main system clock os cillation frequency when aclk is selected as the source clock of the 5-bit counter, substitute the input clock frequency to aclk pin for in the above expression. baud rate = f xin ( 2 n+1 (k+16) ) .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 76 mar. 2005 ver 0.2 17. buzzer function the buzzer driver block consis ts of 6-bit binary counter, buzzer register buzr, and cloc k source selector. it gener- ates square-wave which has very wide range frequency (488hz ~ 250khz at f xin = 4mhz) by user software. a 50% duty pulse can be output to r13 / buzo pin to use for piezo-electric buzzer drive. pin r13 is assigned for out- put port of buzzer driver by setting the bit 2 of psr1(ad- dress 0f9 h ) to ?1?. for psr1 regi ster, refer to figure 17-2 . example: 5khz output at 4mhz. ldm buzr,#0011_0001b ldm psr1,#xxxx_x1xxb x means don?t care the bit 0 to 5 of buzr determines output frequency for buzzer driving. equation of frequency calculation is shown below. f buz : buzzer frequency f xin : oscillator frequency divide ratio: prescaler divide ratio by buck[1:0] bur: lower 6-bit value of buzr. buzzer period value. the frequency of output signal is controlled by the buzzer control register buzr. the bit 0 to bit 5 of buzr deter- mine output frequency for buzzer driving. figure 17-1 block diagram of buzzer driver figure 17-2 buzzer register & psr1 f buz f xin 2 divideratio bur 1 + () ---------------------------------------------------------------------------------- - = prescaler 8 32 16 64 bur r12/buzo pin psr1 internal bus line r13 port data x in pin 2 6 [0e0 h ] [0f9 h ] 0 1 f/f comparator compare data 6-bit binary mux 00 01 10 11 port selection register 1 mux buzo counter bur[5:0] buzr address: 0e0 h reset value: 0ff h wwww ww source clock select 00: f xin 8 01: f xin 16 10: f xin 32 11: f xin 64 buzzer period data ww buck1 buck0 psr1 address: 0f9 h reset value: ---- 0000 b buzo r12 / buzo selection 0: r12 port (turn off buzzer) 1: buzo port (turn on buzzer) - - - - - - - .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 77 the 6-bit counter is cleared an d starts the counting by writ- ing signal at buzr register . it is incremental from 00 h un- til it matches 6-bit bur value. when main-frequency is 4mhz, buzzer frequency is shown as below table 17-1. bur [5:0] bur[7:6] bur [5:0] bur[7:6] 00 01 10 11 00 01 10 11 00 01 02 03 04 05 06 07 250.000 125.000 83.333 62.500 50.000 41.667 35.714 31.250 125.000 62.500 41.667 31.250 25.000 20.833 17.857 15.625 62.500 31.250 20.833 15.625 12.500 10.417 8.929 7.813 31.250 15.625 10.417 7.813 6.250 5.208 4.464 3.906 20 21 22 23 24 25 26 27 7.576 7.353 7.143 6.944 6.757 6.579 6.410 6.250 3.788 3.676 3.571 3.472 3.378 3.289 3.205 3.125 1.894 1.838 1.786 1.736 1.689 1.645 1.603 1.563 0.947 0.919 0.893 0.868 0.845 0.822 0.801 0.781 08 09 0a 0b 0c 0d 0e 0f 27.778 25.000 22.727 20.833 19.231 17.857 16.667 15.625 13.889 12.500 11.364 10.417 9.615 8.929 8.333 7.813 6.944 6.250 5.682 5.208 4.808 4.464 4.167 3.906 3.472 3.125 2.841 2.604 2.404 2.232 2.083 1.953 28 29 2a 2b 2c 2d 2e 2f 6.098 5.952 5.814 5.682 5.556 5.435 5.319 5.208 3.049 2.976 2.907 2.841 2.778 2.717 2.660 2.604 1.524 1.488 1.453 1.420 1.389 1.359 1.330 1.302 0.762 0.744 0.727 0.710 0.694 0.679 0.665 0.651 10 11 12 13 14 15 16 17 14.706 13.889 13.158 12.500 11.905 11.364 10.870 10.417 7.353 6.944 6.579 6.250 5.952 5.682 5.435 5.208 3.676 3.472 3.289 3.125 2.976 2.841 2.717 2.604 1.838 1.736 1.645 1.563 1.488 1.420 1.359 1.302 30 31 32 33 34 35 36 37 5.102 5.000 4.902 4.808 4.717 4.630 4.545 4.464 2.551 2.500 2.451 2.404 2.358 2.315 2.273 2.232 1.276 1.250 1.225 1.202 1.179 1.157 1.136 1.116 0.638 0.625 0.613 0.601 0.590 0.579 0.568 0.558 18 19 1a 1b 1c 1d 1e 1f 10.000 9.615 9.259 8.929 8.621 8.333 8.065 7.813 5.000 4.808 4.630 4.464 4.310 4.167 4.032 3.906 2.500 2.404 2.315 2.232 2.155 2.083 2.016 1.953 1.250 1.202 1.157 1.116 1.078 1.042 1.008 0.977 38 39 3a 3b 3c 3d 3e 3f 4.386 4.310 4.237 4.167 4.098 4.032 3.968 3.907 2.193 2.155 2.119 2.083 2.049 2.016 1.984 1.953 1.096 1.078 1.059 1.042 1.025 1.008 0.992 0.977 0.548 0.539 0.530 0.521 0.512 0.504 0.496 0.488 table 17-1 buzzer frequency (khz unit) .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 78 mar. 2005 ver 0.2 18. interrupts thehms83f012/022 interrupt circuits consist of interrupt enable register (ienh, ienl), interrupt request flags of irqh, irql, priority circuit, and master enable flag (?i? flag of psw). fifteen interr upt sources are provided. the configuration of interrupt circuit is shown in figure 18-1 and interrupt priority is shown in table 18-1. the external interrupts int0 ~ int3 each can be transi- tion-activated (1-to-0 or 0-to-1 transition) by selection ieds register. the flags that actually genera te these interrupts are bit int0if, int1if, int2if and int3if in register irqh. when an external interrupt is generated, the generated flag is cleared by the hardware when the service routine is vec- tored to only if the interrupt was transition-activated. the timer 0 ~ timer 3 interrupts are generated by t0if, t1if, t2if and t3if which is set by a match in their re- spective timer/counter register. the basic interval timer interrupt is generated by bitif which is set by an overfl ow in the timer register. the ad converter interrupt is generated by adcif which is set by finishing the an alog to digital conversion. the watchdog timer is generated by wdtif and wtif which is set by a match in watchdog timer register. figure 18-1 block diagram of interrupt uart rx int2 int1 int0 int0if ienh interrupt enable interrupt enable irqh irql internal bus line register (lower byte) internal bus line register (higher byte) release stop/sleep to cpu interrupt master enable flag i-flag ienl priority control i-flag is in psw, it is cleared by ?di?, set by ?ei? instruction. when it goes interrupt service, i-flag is cleared by hardware, thus any other interrupt are inhibited. when interrupt service is completed by ?reti? instruction, i-flag is set to ?1? by hardware. [0ea h ] [0ec h ] [0ed h ] int1if int2if int3if uartrif t0if sioif int3 uart tx timer 0 serial uarttif timer 1 t1if t3if timer 2 timer 3 t2if a/d converter adcif bitif watchdog timer bit wdtif [0eb h ] communication interrupt vector address generator .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 79 the basic interval timer interrupt is generated by bitif which is set by a overflow in the timer counter register. the uart receive or transmit interrupts are generated by uartrif or uarttif are set by completion of uart data reception or transmission. the sio interrupt is generated by sioif which is set by completion of sio data reception or transmission. the interrupts are controlled by the interrupt master enable flag i-flag (bit 2 of psw on figure 8-3 ), the interrupt en- able register (ienh, ienl), and the interrupt request flags (in irqh and irql) except power-on reset and software brk interrupt. the table 18-1 shows the interrupt priori- ty. vector addresses are shown in figure 8-6 . interrupt enable registers are shown in figure 18-2 . these registers are composed of interrupt enable flags of each interrupt source and these flags determines whet her an interrupt will be ac- cepted or not. when enable flag is ?0?, a corresponding in- terrupt source is prohibited. no te that psw contains also a master enable bit, i-flag, wh ich disables all interrupts at once. figure 18-2 interrupt enable flag register reset/interrupt symbol priority hardware reset external interrupt 0 external interrupt 1 external interrupt 2 external interrupt 3 uart rx interrupt uart tx interrupt serial input/output timer/counter 0 timer/counter 1 timer/counter 2 timer/counter 3 adc interrupt watchdog timer basic interval timer reset int0 int1 int2 int3 int_rx int_tx sio timer 0 timer 1 timer 2 timer 3 adc wdt bit 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 table 18-1 interrupt priority int3e r/w int0e timer/counter 0 interrupt enable flag initial value: 0000 0000 b address: 0ea h ienh int1e msb lsb sioe t0e uartre int2e r/w r/w serial communication interrupt enable flag uart tx interrupt enable flag external interrupt 0 enable flag uart rx interrupt enable flag r/w r/w r/w r/w r/w external interrupt 1 enable flag external interrupt 2 enable flag external interrupt 3 enable flag r/w t1e initial value: 000- 00-0 b address: 0eb h ienl t2e msb r/w timer/counter 3 interrupt enable flag r/w r/w timer/counter 2 interrupt enable flag timer/counter 1 interrupt enable flag lsb r/w adce wdte r/w r/w r/w t3e - - bite basic interval timer interrupt enable flag watchdog timer interrupt enable flag a/d converter interrupt enable flag uartte .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 80 mar. 2005 ver 0.2 figure 18-3 interrupt request flag register 18.1 interrupt sequence an interrupt request is held until the interrupt is accepted or the interrupt latch is cleared to ?0? by a reset or an in- struction. interrupt acceptan ce sequence requires 8 cycles of f xin (2 s at f xin =4mhz) after the completion of the current instruction execution. the interrupt service task is terminated upon execution of an interrupt return instruc- tion [reti]. 18.1.1 interrupt acceptance 1. the interrupt master enable flag (i-flag) is cleared to ?0? to temporarily disable the acceptance of any follow- ing maskable interrupts. when a non-maskable inter- rupt is accepted, the ac ceptance of any following interrupts is temporarily disabled. 2. interrupt request flag for the interrupt source accepted is cleared to ?0?. 3. the contents of the prog ram counter (return address) and the program status word are saved (pushed) onto the stack area. the stack po inter decreases 3 times. 4. the entry address of the interrupt service program is read from the vector table address and the entry address is loaded to the program counter. 5. the instruction stored at th e entry address of the inter- rupt service program is executed. int3if r/w int0if timer/counter 0 interrupt request flag initial value: 0000 0000 b address: 0ec h irqh int1if msb lsb sioif t0if uartrif uarttif int2if r/w r/w serial communication interrupt request flag uart tx interrupt request flag external interrupt 3 request flag uart rx interrupt request flag r/w r/w r/w r/w r/w external interrupt 2 request flag external interrupt 1 request flag external interrupt 0 request flag r/w t1if initial value: 000- 00-0 b address: 0ed h irql t2if msb - timer/counter 3 interrupt request flag r/w r/w timer/counter 2 interrupt request flag timer/counter 1 interrupt request flag lsb - adcif wdtif r/w r/w r/w t3if - - bitif basic interval timer interrupt request flag watchdog timer interrupt request flag a/d converter interrupt request flag .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 81 figure 18-4 timing chart of interrupt acceptance and interrupt return instruction a interrupt request is not accepte d until the i-flag is set to ?1? even if a requested inte rrupt has higher priority than that of the current interrupt being serviced. when nested interrupt service is required, the i-flag should be set to ?1? by ?ei? instru ction in the interrupt service program. in this case, acceptabl e interrupt sources are se- lectively enabled by the indivi dual interrupt enable flags. 18.1.2 saving/restoring general-purpose register during interrupt acceptance processing, the program counter and the program status word are automatically saved on the stack, but accumulator and other registers are not saved itself. these regist ers are saved by the software if necessary. also, when multiple interrupt services are nested, it is necessary to avoid using the same data memory area for saving registers. the following method is used to save/restore the general- purpose registers. example: register save us ing push and pop instruc- tions general-purpose register save/r estore using push and pop instructions; v.l. system clock address bus pc sp sp-1 sp-2 v.h. new pc v.l. data bus not used pch pcl psw adl op code adh instruction fetch internal read internal write interrupt processing step interrupt service task v.l. and v.h. are vector addresses. adl and adh are start addresses of interrupt service routine as vector contents. basic interval timer 012 h 0e3 h 0ffe0 h 0ffe1 h 0e h 2e h 0e312 h 0e313 h entry address correspondence between vector table address for bit interrupt and the entry address of the interrupt service program. vector table address intxx: push a push x push y ;save acc. ;save x reg. ;save y reg. interrupt processing pop y pop x pop a reti ;restore y reg. ;restore x reg. ;restore acc. ;return .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 82 mar. 2005 ver 0.2 18.2 brk interrupt software interrupt can be invoked by brk instruction, which has the lowest priority order. interrupt vector address of brk is shared with the vector of tcall 0 (refer to program memory section). when brk interrupt is generated, b-flag of psw is set to distin- guish brk from tcall 0. each processing step is determined by b-flag as shown in figure 18-5 . figure 18-5 execution of brk/tcall0 18.3 multi interrupt if two requests of different pr iority levels are received si- multaneously, the request of hi gher priority level is ser- viced. if requests of the inte rrupt are received at the same time simultaneously, an inte rnal polling sequence deter- mines by hardware which requ est is serviced. however, multiple processing through soft ware for special features is possible. generally when an interrupt is accepted, the i- flag is cleared to disable an y further interrupt. but as user sets i-flag in interrupt routin e, some further interrupt can main task interrupt service task saving registers restoring registers acceptance of interrupt interrupt return b-flag brk interrupt routine reti tcall0 routine ret brk or tcall0 =0 =1 .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 83 be serviced even if certain interrupt is in progress. figure 18-6 execution of multi interrupt example: during timer1 interrupt is in progress, int0 in- terrupt serviced without any suspend. timer1: push a push x push y ldm ienh,#80h ; enable int0 only ldm ienl,#0 ; disable other int. ei ; enable interrupt : : : : : : ldm ienh,#0ffh ; enable all interrupts ldm ienl,#0ffh pop y pop x pop a reti enable int0 timer 1 service int0 service main program service occur timer1 interrupt occur int0 ei disable other enable int0 enable other in this example, the int0 interrupt can be serviced without any pending, even timer1 is in progress. because of re-setting the interrupt enable registers ienh,ienl and master enable ?ei? in the timer1 routine. .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 84 mar. 2005 ver 0.2 18.4 external interrupt the external interrupt on in t0, int1, int2 and int3 pins are edge triggered depending on the edge selection register ieds (address 0ee h ) as shown in figure 18-7 . the edge detection of external interrupt has three transition activated mode: rising edge, fa lling edge, and both edge. figure 18-7 external interrupt block diagram int0 ~ int3 are multiplexed with general i/o ports (r11, r12, r03, r00). to use as an external interrupt pin, the bit of port selection register psr 0 should be set to ?1? corre- spondingly. example: to use as an int0 and int2 : ; **** set external interrupt port as pull-up state. ldm pu1,#0000_0101b ; ; **** set port as an external interrupt port ldm psr0,#0000_0101b ; ; **** set falling-edge detection ldm ieds,#0001_0001b : response time the int0 ~ int3 edge are latched into int0if ~ int3if at every machine cycle. the values are not actually polled by the circuitry until the next m achine cycle. if a request is active and conditions are right for it to be acknowledged, a hardware subroutine call to th e requested service routine will be the next instruction to be executed. the div itself takes twelve cycles. thus, a minimum of twelve complete machine cycles elapse between activation of an external interrupt request and the beginning of execution of the first instruction of the service routine. figure 18-8 shows interrupt response timings. figure 18-8 interrupt response timing diagram int0if int0 pin int0 interrupt int1if int1 pin int1 interrupt int2if int2 pin int2 interrupt ieds [0eeh] int3if int3 pin int3 interrupt edge selection register 2 2 2 2 01 10 11 01 10 11 01 10 11 01 10 11 interrupt goes active interrupt latched interrupt processing interrupt routine 8 f xin max. 12 f xin .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 85 figure 18-9 ieds register and port selection register psr0 btcl wwwwwwww ec1e pwm1o pwm3o int1e 0: r11 1: int0 initial value: 00 h address: 0f8 h psr0 ec0e int0e int2e int3e 0: r12 1: int1 0: r03 1: int2 0: r00 1: int3 0: r11 1: pwm3o 0: r07 1: ec1 0: r04 1: ec0 lsb msb btcl wwwwwwww ied2h ied3l ied3h ied0h initial value: 00 h address: 0ee h ieds ied2l ied0l ied1l ied1h lsb msb edge selection register 00: reserved 01: falling (1-to-0 transition) 10: rising (0-to-1 transition) 11: both (rising & falling) int0 int1 int2 int3 0: r10 1: pwm1o .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 86 mar. 2005 ver 0.2 19. power saving operation thehms83f012/022 has two power-down modes. in power-down mode, power consumption is reduced considerably. for applications where power consumption is a critical factor, device pr ovides two kinds of power sav- ing functions, stop mode and sleep mode. table 19-1 shows the status of each power saving mode. sleep mode is entered by the sscr re gister to ?0fh?., and stop mode is entered by stop instruction after the sscr regis- ter to ?5ah?. 19.1 sleep mode in this mode, the internal oscillation circuits remain active. oscillation continues and peripherals are operate normally but cpu stops. movement of all peripherals is shown in table 19-1. sleep mode is entered by setting the sscr register to ?0fh?. it is released by reset or interrupt. to be released by interrupt, interrupt should be enabled before sleep mode. figure 19-1 stop and sleep control register release the sleep mode the exit from sleep mode is hardware reset or all inter- rupts. reset re-defines all the control registers but does not change the on-chip ram. interrupts allow both on-chip ram and control registers to retain their values. if i-flag = 1, the normal inte rrupt response takes place. if i- flag = 0, the chip will resu me execution starting with the instruction following the sleep instruction. it will not vector to interrupt service routine. (refer to figure 19-4 ) when exit from sleep mode by reset, enough oscillation stabilizing time is required to normal operation. figure 19- 3 shows the timing diagram. when released from the sleep mode, the basic interval timer is activated on wake-up. it is increased from 00 h until ff h . the count overflow is set to start normal operation. th erefore, before sleep instruction, user must be set its relevant prescaler divide ratio to have long enough time (more than 20msec). this guarantees that oscillator has started and stabilized. by interrupts, exit from sleep mode is shown in figure 19-2 . by reset, exit from sleep mode is shown in figure 19-3 . 76543210 initial value: 0000 0000 b address: 0f5 h sscr w power down control 5a h : stop mode 0f h : sleep mode w w w w w w w note : to get into stop mode, sscr must be set to 5ah just before stop instruction execution. at stop mode, stop & sleep control register (sscr) value is cleared automatically when released. to get into sleep mode, sscr must be set to 0fh . .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 87 . figure 19-2 sleep mode release timing by external interrupt figure 19-3 timing of sl eep mode release by reset 19.2 stop mode in the stop mode, the main os cillator, system clock and pe- ripheral clock is stopped, but rc-oscillated watchdog tim- er continue to oper ate. with the clock frozen, all functions are stopped, but the on-chip ram and control registers are held. the port pins out the values held by their respective port data register, port direction registers. oscillator stops and the systems internal op erations are all held up. ? the states of the ram, registers, and latches valid immediately before the system is put in the stop state are all held. ? the program counter stop the address of the instruction to be execut ed after the instruction "stop" which starts the stop operating mode. note: the stop mode is activated by execution of stop instruc- tion after setting the sscr to ?5a h ?. (this register should be writ- ten by byte operation. if this register is set by bit manipulation instruction, for example "set1" or "clr1" instruction, it may be undes- ired operation) in the stop mode of operation, v dd can be reduced to min- imize power consumption. care must be taken, however, to ensure that v dd is not reduced before the stop mode is invoked, and that v dd is restored to its normal operating level, before the stop mode is terminated. oscillator (x in pin) ~ ~ normal operation sleep operation ~ ~ ~ ~ ~ ~ ~ ~ external interrupt internal clock sleep instruction executed ~ ~ normal operation ~ ~ ~ ~ ~ ~ sleep instruction stabilization time t st = 65.5ms @4mhz internal ~ ~ ~ ~ ~ ~ reset reset oscillator (x in pin) ~ ~ cpu clock ~ ~ ~ ~ execution normal operation sleep operation normal operation .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 88 mar. 2005 ver 0.2 the reset should not be activated before v dd is restored to its normal operating level, and must be held active long enough to allow the oscillator to restart and stabilize. note: after stop instruction, at least two or more nop instruc- tion should be written. ex) ldm ckctlr,#0fh ;more than 20ms ldm sscr,#5ah stop nop ;for stabilization time nop ;for stabilization time in the stop operation, the dissipation of the power asso- ciated with the oscillator and the internal hardware is low- ered; however, the power dissipation associated with the pin interface (dependi ng on the external circuitry and pro- gram) is not directly determined by the hardware operation of the stop feature. this point should be little current flows when the input level is stable at the power voltage level (v dd /v ss ); however, when the input level gets high- er than the power voltage level (by approximately 0.3 to 0.5v), a current begins to flow. therefore, if cutting off the output transistor at an i/o port puts the pin signal into the high-impedance state, a current flow across the ports input transistor, requiring to fix the level by pull-up or other means. release the stop mode the source for exit from stop mode is hardware reset, ex- ternal interrupt, timer(ec0,1 ), watch timer, wdt, sio or uart. reset re-defines al l the control registers but does not change the on-chip ra m. external interrupts al- low both on-chip ram and control registers to retain their values. if i-flag = 1, the normal inte rrupt response takes place. if i- flag = 0, the chip will resu me execution starting with the instruction following the stop instruction. it will not vec- tor to interrupt service routine. (refer to figure 19-4 ) when exit from stop mode by external interrupt, enough oscillation stabilizing time is required to normal operation. figure 19-5 shows the timing diagram. when released from the stop mode, the basic interval timer is activated on wake-up. it is increased from 00 h until ff h . the count overflow is set to start normal operation. th erefore, before stop instruction, user must be set its relevant prescaler di- vide ratio to have long enough time (more than 20msec). this guarantees that oscillat or has started and stabilized. peripheral stop mode sleep mode cpu stop stop ram retain retain basic interval timer halted operates continuously watchdog timer stop (only operates in rc-wdt mode) stop timer/counter halted (only when the event counter mode is enabled, timer operates normally) operates continuously buzzer, adc stop stop sio only operate with external cloc k only operate with external clock uart only operate with external cloc k only operate with external clock oscillator stop (x in =l, x out =h) oscillation i/o ports retain retain control registers retain retain internal circuit stop mode sleep mode prescaler retain active address data bus retain retain release source reset, timer(ec0,1), sio, uart(using aclk), watchdog timer (rc-wdt mode), external interrupt reset, all interrupts table 19-1 peripheral operation during power saving mode .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 89 by reset, exit from stop mode is shown in figure 19-6 . figure 19-4 stop releasing flow by interrupts . figure 19-5 stop mode release timing by external interrupt ienh or ienl ? =0 =1 stop instruction stop mode interrupt request stop mode release i-flag =1 interrupt service routine next instruction =0 master interrupt enable bit psw[2] corresponding interrupt enable bit (ienh, ienl) before executing stop instruction, basic interval timer must be set oscillator (x in pin) ~ ~ n 0 bit counter n+1 n+2 n+3 ~ ~ normal operation stop operation normal operation 1 fe ff 0 12 ~ ~ ~ ~ ~ ~ t st > 20ms ~ ~ ~ ~ external interrupt internal clock clear stop instruction executed ~ ~ ~ ~ ~ ~ properly by software to get stabilization time which is longer than 20ms. by software ~ ~ stabilization time .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 90 mar. 2005 ver 0.2 figure 19-6 timing of stop mode release by reset 19.3 stop mode at internal rc-oscillated watchdog timer mode in the internal rc-oscillated watchdog timer mode, the on-chip oscillator is stopped. but internal rc oscillation circuit is oscillated in th is mode. the on-chip ram and control registers are held. the port pins out the values held by their respective port data register, port direction regis- ters. the internal rc-oscillated watchdog timer mode is acti- vated by execution of stop instruction after setting the bit rcwdt of ckctlr to "1". (thi s register should be writ- ten by byte operation. if this register is set by bit manipu- lation instruction, for example "set1" or "clr1" instruction, it may be undesired operation) note: caution: after stop instruction, at least two or more nop instruction should be written ex) ldm wdtr,#1111_1111b ldm ckctlr,#0010_1110b ldm sscr,#0101_1010b stop nop ;for stabilization time nop ;for stabilization time the exit from internal rc-oscillated watchdog timer mode is hardware reset or external interrupt or watchdog timer interrupt (at rc-watchdog timer mode). reset re-de- fines all the control registers but does not change the on- chip ram. external interrupts allow both on-chip ram and control registers to retain their values. if i-flag = 1, the normal in terrupt response takes place. in this case, if the bit wdton of ckctlr is set to "0" and the bit wdte of ienh is set to "1", the device will execute the watchdog timer interrupt service routine(figure 8-6 ). however, if the bit wdton of ckctlr is set to "1", the device will generate the internal reset signal and execute the reset processing(figure 19-8 ). if i-flag = 0, the chip will resume execution starting with the instruction follow- ing the stop instruction. it will not vector to interrupt ser- vice routine.(refer to figure 19-4 ) when exit from stop mode at internal rc-oscillated watchdog timer mode by external interrupt, the oscilla- tion stabilization time is required to normal operation. fig- ure 19-7 shows the timing diagram. when release the internal rc-oscillated watchdog timer mode, the basic interval timer is activated on wake-up. it is increased from 00 h until ff h . the count overflow is set to start normal op- eration. therefore, before st op instruction, user must be set its relevant prescaler divi de ratio to have long enough time (more than 20msec). this guarantees that oscillator has started and stabilized. by re set, exit from internal rc- oscillated watchdog timer mode is shown in figure 19-8 . ~ ~ stop mode time can not be control by software oscillator (xi pin) ~ ~ ~ ~ ~ ~ stop instruction execution stabilization time t st = 65.5ms @4mhz internal clock internal ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ reset reset .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 91 figure 19-7 stop mode release at internal rc-wd t mode by external inte rrupt or wdt interrupt figure 19-8 internal rc-wdt mode releasing by reset ~ ~ stop mode normal operation oscillator (x in pin) ~ ~ ~ ~ n+1 nn+2 00 01 fe ff 00 00 n-1 n-2 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ clear basic interval timer stop instruction execution normal operation stabilization time t st > 20ms internal clock external interrupt bit counter ~ ~ internal rc clock ( or wdt interrupt ) at rc-wdt mode ~ ~ oscillator (x in pin) ~ ~ ~ ~ ~ ~ ~ ~ internal clock internal rc clock time can not be control by software ~ ~ stop instruction execution stabilization time t st = 65.5ms @4mhz internal ~ ~ ~ ~ ~ ~ reset by wdt reset reset rcwdt mode .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 92 mar. 2005 ver 0.2 19.4 minimizing current consumption the stop mode is designed to reduce power consumption. to minimize current drawn during stop mode, the user should turn-off output drivers that are sourcing or sinking current, if it is practical. figure 19-9 application example of unused input port figure 19-10 application example of unused output port note: in the stop operation, the power dissipation associated with the oscillator and the inter nal hardware is lowered; however, the power dissipation associated with the pin interface (depending on the external circuitry and program) is not directly determined by the hardware operation of the stop feature. this point should be little current flows when the input level is stable at the power volt- age level (v dd /v ss ); however, when the input level becomes high- er than the power voltage level (by approximately 0.3v), a current begins to flow. therefore, if cutting off the output transistor at an i/ o port puts the pin signal into the high-impedance state, a current flow across the ports input transistor, requiring it to fix the level by pull-up or other means. it should be set properly in order that current flow through port doesn't exist. first consider the port setting to input mode. be sure that there is no current flow after considering its relationship with external circuit. in input mode, the pin impedance input pin v dd gnd i v dd x weak pull-up current flows v dd internal pull-up input pin i v dd x very weak current flows v dd o o open open i=0 o i=0 o gnd when port is configured as an input, input level should be closed to 0v or 5v to avoid power consumption. output pin gnd i in the left case, much current flows from port to gnd. x on off output pin gnd i in the left case, tr. base current flows from port to gnd. i=0 x off on v dd l on off open gnd v dd l on off to avoid power consumption, there should be low output on off o o v dd o to the port . .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 93 viewing from external mcu is very high that the current doesn?t flow. but input voltage level should be v ss or v dd . be careful that if unspecified voltage, i. e. if uncertain voltage level (not v ss or v dd ) is applied to input pin, there can be little current (max. 1ma at around 2v) flow. if it is not appropriate to set as an input mode, then set to output mode considering there is no current flow. the port setting to high or low is decided by considering its rela- tionship with external circuit. for example, if there is ex- ternal pull-up resistor then it is set to output mode, i.e. to high, and if there is external pull-down register, it is set to low. .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 94 mar. 2005 ver 0.2 20. reset the hms83f012/022 supports various kinds of reset as below. ? power-on reset (por) ? reset (external reset circuitry) ? watchdog timer timeout reset ? power-fail detection (pfd) reset ? address fail reset figure 20-1 reset block diagram the on-chip por circuit holds down the device in reset until v dd has reached a high enough level for proper op- eration. it will eliminate exte rnal components such as reset ic or external resistor and capacitor for external reset cir- cuit. in addition that the reset pin can be used to normal input port r35 by setting ?por? and ?r35en? bit config- uration area(20ffh) in the fl ash programming. when the device starts normal operati on, its operating parmeters (voltage, frequency, temperat ure...etc) must be met. .table 20-1 shows on-chip hardware initialization by reset action. table 20-1 initializing internal status by reset action the reset input is the reset pin, which is the input to a schmitt trigger. a reset in accomplished by holding the reset pin low for at least 8 oscillator periods, within the operating voltage range and oscillation stable, it is applied, and the internal state is initialized. after reset, 65.5ms (at 4 mhz) add with 7 oscillator periods are required to start execution as shown in figure 20-2 . internal ram is not affected by reset. when v dd is turned on, the ram content is inde terminate. therefore, this ram should be initialized before read or tested it. when the reset pin input goes to high, the reset opera- tion is released and the program execution starts at the vec- tor address stored at addresses fffe h - ffff h . a connection for simple power-on-reset is shown in figure 20-1 . por (power-on reset) address fail reset pfd (power-fail detection) wdt (wdt timeout reset) s r q bit internal reset reset clear overflow noise canceller on-chip hardware initial value on-chip hardware initial value program counter (pc) (ffff h ) - (fffe h ) peripheral clock off ram page register (rpr) 0 watchdog timer disable g-flag (g) 0 control registers refer to table 8-1 on page 22 operation mode main-frequency cl ock power fail detector disable .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 95 figure 20-1 simple power-on-reset circuit figure 20-2 timing diagram after reset the address fail reset is the function to reset the system by checking code access of abnormal and unwished ad- dress caused by erroneous program code itself or external noise, which could not be returned to normal operation and would become malfunction state. if the cpu tries to fetch the instruction from ineffectiv e code area or ram area, the address fail reset is occurred. please refer to figure 11-2 for setting address fail option. 7036p v cc 10uf + 10k ? to the reset pin main program oscillator (x in pin) ? ? fffe ffff stabilization time t st =65.5ms at 4mhz reset address data 1 2 3 4 5 6 7 ?? start ? ? ? fe ? adl adh op bus bus reset process step ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ t st = x 256 f xin 1024 1 .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 96 mar. 2005 ver 0.2 21. power fail processor thehms83f012/022 has an on-chip power fail detection circuitry to immunize against power noise. a configura- tion register, pfdr, can enable or disable the power fail detect circuitry. whenever v dd falls close to or below power fail voltage for 100ns, the power fail situation may reset or freeze mcu according to pfdm bit of pfdr. re- fer to ?figure 21-1 power fail voltage detector register? on page 96. in the in-circuit emulator, power fail function is not imple- mented and user can not exper iment with it. therefore, af- ter final development of user program, this function may be experimented or evaluated. figure 21-1 power fail voltage detector register figure 21-2 example s/w of reset flow by power fail pfdm 76543210 pfds initial value: ---- -000 b address: 0f7 h pfdr r/w r/w r/w pfden pfd operation mode 0 : mcu will be frozen by power fail detection 1 : mcu will be reset by power fail detection pfd enable bit 0: power fail detection disable 1: power fail detection enable power fail status 0: normal operate 1: set to ?1? if power fail is detected * cautions : be sure to set bits 3 through 7 to ?0?. ----- function execution initialize ram data pfds =1 no reset vector initialize all ports initialize registers ram clear yes skip the initial routine pfds = 0 .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 97 figure 21-3 power fail processor situations (at 4mhz operation) internal reset internal reset internal reset v dd v dd v dd v pfd max v pfd min v pfd max v pfd min v pfd max v pfd min 65.5ms 65.5ms t < 65.5ms 65.5ms when pfdm = 1 .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 98 mar. 2005 ver 0.2 22. countermeasure of noise 22.1 oscillation noise protector the oscillation noise protector (onp) is used to supply stable internal system clock by excluding the noise which could be entered into oscillator and recovery the oscillation fail. this function could be enabled or disabled by the ?onp? bit of the device configuration area (20ff h ) for the hms83f022, ?onp? option bits mask option. the onp function is like below. - recovery the oscillation wave crushed or loss caused by high frequency noise. - change system clock to th e internal oscillation clock when the high frequency noise is continuing. - change system clock to th e internal oscillation clock when the x in /x out is shorted or opened, the main oscillation is stopped except by stop instruction and the low frequency noise is entered. figure 22-1 block diagram of onp & ofp and respective wave forms lf noise hf noise canceller hf noise observer mux clk changer internal osc ofp ofp o/f ck ps10 f internal int_clk xin_nf xin onp in4(2)mclk(xo) (8-bit counter) en onp ofp en en 0 0 1 1 s s onpb = 0 lf_on = 1 in_clk = 0 clk_chg xin_nf int_clk reset int_clk ofp_en chg_end clk_chg f internal ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ high frq. noise xin ~ ~ ~ ~ noise cancel int_clk 8 periods (250ns 8 =2us) low frq. noise or oscillation fail clock change start(xin to int_clk) ps10(int_clk/512) 256 periods (250ns 512 256 =33 ms) clock change end(int_clk to xin)) observer .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 99 22.2 oscillation fail processor the oscillation fail processor (ofp) can change the clock source from external to intern al oscillator when the oscil- lation fail occured. this function could be enabled or dis- abled by the ?ofp? bit of the device configuration area (mask option for hms83c012/022). and this function can recove r the external clock source when the external clock is recovered to normal state. in4(2)mclk/clkxo(xo) option the ?in4mclk(xo)?, ?in2mc lk(xo)? bit of the de- vice configuration area (mask option for hms83c012/ 022) enables the function to operate the device by using the internal oscillator clock in onp block as system clock. there is no need to connect th e x-tal, resonator, rc and r externally. the user on ly to connect the x in pin to v dd . after selecting the this option, the period of internal oscil- lator clock could be checked by x out outputting clock di- vided the internal oscillator clock by 4. .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 100 mar. 2005 ver 0.2 23. device configuration area the device configuration area can be programmed or left unprogrammed to select de vice configuration such as por, onp, clk option and secu rity bit. this area is not accessible during normal execu tion but is readable and writable during flash program / verify mode. figure 23-1 device configuration area 76543210 initial value: 00 h address: 20ff h configuration option bits oscillation confuguration 000 : in4mclk (internal 4mhz oscillation & r33/r34 enable) 001 : in2mclk (internal 2mhz oscillation & r33/r34 enable) clk2 onp ofp lock por r35en clk1 clk0 010 : exrc (external r/rc oscillation & r34 enable) 011 : x-tal (crystal or resonator oscillation) 100 : in4mclkxo (internal 4mhz oscillation & r33 enable & xout = f sys 4) 101 : in2mclkxo (internal 2mhz oscillation & r33 enable & xout = f sys 4) 110 : exrcxo (external r/rc oscillation & xout = f sys 4) 111 : prohibited reset /r35 port configuration 0 : r35 port disable (use reset ) 1 : r35 port ensable (disable reset ) por use 0 : disable por reset 1 : ensable por reset security bit 0 : enable reading user code 1 : disable reading user code ofp use 0 : disable ofp (clock changer) 1 : enable ofp (clock changer) onp disable 0 : enable onp (enable ofp, internal 4mhz/2mhz oscillation) 1 : disable onp (disable ofp, internal 4mhz/2mhz oscillation) .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 101 24. mask option (mc80c0316) the mc80c0316 has several mask option which config- ures the package type or use of some special features of the device. the mask option of the mask order sheet should be checked to select device configuration such as package type, oscillation selection, oscillation noise pro- tector, oscillation fail protector, internal 4mhz, amount of noise to be cancelled. table 24-1 mask options option check operation remark mask option package 28 skdip 28 skdip type package select 32 pdip 32 pdip type package select onp yes onp enable osc noise protector(onp) operation en/disable bit no onp disable ofp yes enables oscillation fail processor (onp clock changer) change the inter clock when oscillation failed no disables oscillation fail processor (onp clock changer ) por yes enables por to select power-on reset no disables por r35en yes r35 port enable (disable reset ) to use r35 port as nomarl input port no r35 port disable (use reset ) clk option crystal crystal oscillation to select oscillation type exrc external r/rc oscillation & r33 enable in4mclk internal 4mhz oscillation & r33/r34 enable in2mclk internal 2mhz oscillation & r33/r34 enable exrcxo external r/rc oscillation & r33 enable x out pin : system clock 4 in4mclkxo internal 4mhz oscillation & r33 enable x out pin : system clock 4 in2mclkxo internal 2mhz oscillation & r33 enable x out pin : system clock 4 .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 102 mar. 2005 ver 0.2 25. emulator eva. board setting ?? ? ?????? ? ? ? ? ? ? ? .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 103 dip switch and vr setting before execute the user program, keep in your mind the be- low configuration dip s/w descripti on on/off setting - this connector is only used for a devi ce over 32 pin. for the hms83f027/25/23. - this connector is only used for a device under 32 pin. for the mc80f0316. sw2 1 eva. select switch must be off position. on : for the hms83f027/25/23. off : for the mc80f0316. 2 3 av dd pin select switch these switches select the av dd source. on & off : use eva. v dd off & on : use user av dd 4 this switch select the /reset source. normally off . eva. chip can be reset by external user tar- get board. on : reset is available by either user target system board or emulator reset switch. off : reset the mcu by emulator reset switch. does not work from user target board. 5 this switch select the xout signal on/off. normally off . mcu xout pin is disconnected internally in the emulator. some circumstance user may connect this circuit. on : output xout signal off : disconnect circuit sw3 1 this switch select eva. b/d power supply source. normally mds . this switch select eva. b/d power supply source. sw4 1 2 this switch select the r22 or sx out . this switch select the r21 or sx in . these switchs sele ct the normal i/o port(off) or sub-clock (on). it is reserved for the mc80f0448. on : sx out , sx in off : r22, r21 don?t care (hms83f027/25/23). ? ? ? on on off off on use eva. v dd use user?s av dd ? use mds power mds user mds user use user?s power ? .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 104 mar. 2005 ver 0.2 sw5 1 2 these switches select the r33 or x in this switch select the normal i/o port(on&off) or special function select(off&on). it is reserved for the mc80f0316. on & off : r33,r34,r35 port selected. off & on : x out , x in , /reset selected. don?t care (hms83f027/25/23). 3 4 these switches select the r34 or x out 5 6 these switches select the r35 or /reset - this is external oscillation socket(can type. osc) this is for external clock(can type. osc). dip s/w descripti on on/off setting ? ? .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 105 26. in-system programming (isp) 26.1 getting started / installation the following section details the procedure for accomplishing the installation procedure. 1. connect the serial(rs-232 c) cable between a target board and the com port of your pc. 2. configure the com port of your pc as following. 3. turn your target b/d power switch on. your target b/ d must be configured to enter the isp mode. 4. run the magnachip isp software. 5. press the reset button in th e isp s/w. if the status win- dows shows a message as "connected", all the condi- tions for isp are provided. 26.2 basic isp s/w information baudrate 115,200 data bit 8 parity no stop bit 1 flow control no .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 106 mar. 2005 ver 0.2 function description load hex file load the data from the selected file storage into the memory buffer. save hex file save the current data in your memory buff er to a disk storage by using the intel motorolla hex format. erase erase the data in your target mcu before programming it. blank check verify whether or not a device is in an erased or unprogrammed state. program this button enables you to place new data fr om the memory buffer in to the target device. read read the data in the target mcu into the buffer for examination. the checksum will be displayed on the checksum box. verify assures that data in the device matches data in the memory buffer. if your device is secured, a verification error is detected. option write progam the configuration data of target mcu. the security locking is performed with this button. option set the configuration data of target mcu. the security lo cking is set with this button. auto erase & program & verify. auto option write if selected with check mark, the option write is performed after erasure and write. edit buffer modify the data in the selected address in your buffer memory fill buffer fill the selected area with a data. goto display the selected page. osc. ______ mhz enter your target system?s oscillator value with discarding below point. start ______ starting address end ______ end address checksum display the checksum(hexdecimal) after reading th e target device. com port select serial port. baud rate select uart baud rate. select device sele ct target device. page up key display the previous page of your memory buffer. page down key display the higher page than the current location. table 1. isp function description .com .com .com .com 4 .com u datasheet
preliminary mc80f0304/08/16 mar. 2005 ver 0.2 107 26.3 hardware conditions to enter the isp mode the in-system programming (is p) is performed without removing the microcontroller from the system. the in- system programming (isp) facility consists of a series of internal hardware resources coupled with internal firm- ware through the serial port. the in-system programming (isp) facility has made in-circuit programming in an em- bedded application possible with a minimum of additional expense in components and circuit board area. the boot loader can be executed by holding ale high, reset /v pp as +9v, and aclk with the osc. 1.8432mhz. the isp function uses five pins: txd, rxd, aleb, aclk and re- set /v pp . note: considerations to implement isp function in a user target board ? the aclk must be connected to the specifed oscillator. ? connect the +9v to reset /vpp pin directly. ?the ale pin must be pulled high. ? the main clk must be higher than 2mhz. v dd reset x in x out v ss r05 / txd r04 / rxd r05 / aclk r10 isp configuration mcu txd mcu rxd high(1) v dd (+5v) +9v 2 3 4 5 6 7 8 27 26 25 24 23 22 21 128 9 10 11 12 13 14 20 19 18 17 16 15 2mhz~12mhz aclk_clk ale x-tal reset /v pp .com .com .com .com 4 .com u datasheet
mc80f0304/08/16 preliminary 108 mar. 2005 ver 0.2 26.4 reference isp circuit diagram and magnachip supplied isp board the isp software and hardware circuit diagram are provided at www.magnachipmcu.com . to get a isp b/d, contact to sales de- partment. the following circuit diagram is for reference use. figure 1. referen ce isp circuit diagram figure 2. magnachip supplied isp board t1in t2in r1out r2out c1+ c1- c2+ c2- t1out t2out r1in r2in v+ vcc v- gnd con1 female db9 j2 v ss v dd j3 external v dd reset /v pp mcu_txd mcu_rxd v dd v ss 10uf/16v 0.1uf max232 aclk_clk vcc out gnd osc x1 1.8432mhz 22 ? 0.1uf 100 ? the ragne of v dd must be from 4.5 to 5.5v and isp function is not supported under 2mhz system clock. if the user supplied v dd is out of range, the external power is needed instead of the target system v dd . v dd (+5v) v ss v dd (+5v) v ss 14 7 13 8 2 16 6 15 11 10 12 9 1 3 4 5 v ss v ss 1 2 3 4 5 v ss v dd (+5v) 6 1uf 1uf 0.1uf 1uf 1uf 5 9 4 8 3 7 2 6 1 * v pp : v dd + 4v * v dd : +4.5 ~ +5.5v to pc to mcu gnd txd rxd + + + + + for the isp operation, power cons umption required is minimum 30ma. v dd v ss .com .com .com 4 .com u datasheet


▲Up To Search▲   

 
Price & Availability of MC83C0304

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X